Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Facebook Login in ios application #97

Closed
yugalkishoregoyal opened this issue Apr 29, 2015 · 23 comments
Closed

Facebook Login in ios application #97

yugalkishoregoyal opened this issue Apr 29, 2015 · 23 comments

Comments

@yugalkishoregoyal
Copy link

Hi,
I implemented Instagram Login in my app , that worked like charm !! Thanks for it :)
Now I'm implementing facebook login , I'm copying this code in my appdelegate( am I doing it right ?).
SimpleAuth.configuration()["facebook"] = [
"app_id" : ""
]
It is saying " Called Object type NSMutableDictionary is not a function or a function pointer "
I'm going to test it on simulator , will it work ?

@calebd
Copy link
Owner

calebd commented Apr 29, 2015

Sorry about that. Pushing an update to CocoaPods right now.

@calebd
Copy link
Owner

calebd commented Apr 29, 2015

Done!

$ pod update SimpleAuth

@yugalkishoregoyal
Copy link
Author

Hi,
Thanks for the quick response.
But it did't resolved the issue. I'm attaching a screenshot if that helps you in understanding the problem.
screen

@calebd
Copy link
Owner

calebd commented Apr 29, 2015

You can't type Swift into Objective-C files.

@calebd
Copy link
Owner

calebd commented Apr 29, 2015

You want SimpleAuth.configuration[@"facebook"] = @{};

@yugalkishoregoyal
Copy link
Author

Hi,
That worked !! Thanks !
Sorry to bother you again , but in Instagram we have access token in the responseObject.
How do we access profile picture or Display name of user in facebook ?

@calebd
Copy link
Owner

calebd commented Apr 29, 2015

The Facebook response object is built here. Refer to that for all keys that you can use as a SimpleAuth consumer.

@yugalkishoregoyal
Copy link
Author

I've tried the keys but I keep getting NS Exception error " this class is not key value coding-compliant for the key token.'
can you help me how to correctly access the keys ?
Thanks.

@calebd
Copy link
Owner

calebd commented Apr 29, 2015

It's just a dictionary...

SimpleAuth.authorize("facebook", completion: { responseObject, error in
    let dictionary = responseObject as? [String: AnyObject]
    let credentials = dictionary?["credentials"] as? [String: AnyObject]
    let token = credentials?["token"] as? String
    println("\(__FUNCTION__) \(token)")
})

Or Objective-C if you're into that kind of thing:

[SimpleAuth authorize:@"facebook" completion:^(id responseObject, NSError *error) {
    NSDictionary *dictionary = responseObject;
    NSString *token = dictionary[@"credentials"][@"token"];
    NSLog(@"%s %@", __PRETTY_FUNCTION__, token);
}];

@yugalkishoregoyal
Copy link
Author

I tried that method before , it is returning null.
screen2

@calebd
Copy link
Owner

calebd commented Apr 30, 2015

Have you tried logging responseObject to see what it's structure is? It's possible that the request is failing along the way. In that case, responseObject will be nil and error will contain some potentially useful information.

@yugalkishoregoyal
Copy link
Author

Yes tried, it is returning null only.
screen3

@calebd
Copy link
Owner

calebd commented Apr 30, 2015

And the error?

@yugalkishoregoyal
Copy link
Author

Hi,
When I tried to logging the error , I got following issues.

  1. When I used account other than the account from which I created the application. I got following error.
    screen

  2. When I used same account from which I created the facebook application, it hits the NSexception.
    screen2

@calebd
Copy link
Owner

calebd commented May 6, 2015

Can you confirm what version of SimpleAuth you have installed?

@yugalkishoregoyal
Copy link
Author

Its the latest version.. I have installed it 2 days ago.

@calebd
Copy link
Owner

calebd commented May 6, 2015

The most recent time you installed it isn’t really relevant. CocoaPods will lock pods to their initial versions unless you update them explicitly. Can you either confirm which version you have installed, or run pod update SimpleAuth?

@yugalkishoregoyal
Copy link
Author

Its 0.3.9

screen_pod

@calebd
Copy link
Owner

calebd commented May 7, 2015

It works fine for me... Can you paste the exception stack trace?

@yugalkishoregoyal
Copy link
Author

Hi,
I'm not sure if its the exception stack trace you are talking about.

    0   CoreFoundation                      0x000000010dca2f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d93bbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010dcaa04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010dc0227c ___forwarding___ + 988
    4   CoreFoundation                      0x000000010dc01e18 _CF_forwarding_prep_0 + 120
    5   fb Login                            0x000000010bf21512 -[SimpleAuthFacebookProvider credentialsDictionaryWithRemoteAccount:systemAccount:] + 114
    6   fb Login                            0x000000010bf21295 -[SimpleAuthFacebookProvider responseDictionaryWithRemoteAccount:systemAccount:] + 229
    7   CoreFoundation                      0x000000010db9ac8c __invoking___ + 140
    8   CoreFoundation                      0x000000010db9aae2 -[NSInvocation invoke] + 290
    9   CoreFoundation                      0x000000010dc29ed6 -[NSInvocation invokeWithTarget:] + 54
    10  fb Login                            0x000000010beb06c3 __63-[NSObject(RACLifting) rac_liftSelector:withSignalOfArguments:]_block_invoke + 195
    11  fb Login                            0x000000010bf09d1c __29-[RACStream(Operations) map:]_block_invoke + 76
    12  fb Login                            0x000000010bf0951c __36-[RACStream(Operations) flattenMap:]_block_invoke_2 + 92
    13  fb Login                            0x000000010bf01d72 __29-[RACSignal(RACStream) bind:]_block_invoke125 + 130
    14  fb Login                            0x000000010bf11adf -[RACSubscriber sendNext:] + 239
    15  fb Login                            0x000000010bed053c -[RACPassthroughSubscriber sendNext:] + 444
    16  fb Login                            0x000000010beec9c0 __35-[RACSignal(Operations) takeUntil:]_block_invoke568 + 96
    17  fb Login                            0x000000010bf11adf -[RACSubscriber sendNext:] + 239
    18  fb Login                            0x000000010bed053c -[RACPassthroughSubscriber sendNext:] + 444
    19  fb Login                            0x000000010bf01840 __29-[RACSignal(RACStream) bind:]_block_invoke_298 + 96
    20  fb Login                            0x000000010bf11adf -[RACSubscriber sendNext:] + 239
    21  fb Login                            0x000000010bed3dc1 __29-[RACReturnSignal subscribe:]_block_invoke + 81
    22  fb Login                            0x000000010bed5e80 -[RACScheduler performAsCurrentScheduler:] + 512
    23  fb Login                            0x000000010bed1514 __30-[RACQueueScheduler schedule:]_block_invoke + 84
    24  libdispatch.dylib                   0x000000010f1d9ba6 _dispatch_call_block_and_release + 12
    25  libdispatch.dylib                   0x000000010f1f77f4 _dispatch_client_callout + 8
    26  libdispatch.dylib                   0x000000010f1dfb22 _dispatch_queue_drain + 1417
    27  libdispatch.dylib                   0x000000010f1df432 _dispatch_queue_invoke + 235
    28  libdispatch.dylib                   0x000000010f1e1fc1 _dispatch_root_queue_drain + 685
    29  libdispatch.dylib                   0x000000010f1e3612 _dispatch_worker_thread2 + 52
    30  libsystem_pthread.dylib             0x000000010f58fef8 _pthread_wqthread + 314
    31  libsystem_pthread.dylib             0x000000010f592fb9 start_wqthread + 13

@calebd
Copy link
Owner

calebd commented May 7, 2015

Ok. This bug was only present in 0.3.8, fixed in 0.3.9 (9b7830b). So maybe you need to clean your build, nuke derived data, or something. This works in 0.3.9. Maybe try a clean and see if that helps?

@yugalkishoregoyal
Copy link
Author

That worked :))
Can we access facebook friend list with your pods ?

@calebd
Copy link
Owner

calebd commented May 7, 2015

Sorry for the confusion. Yay Xcode.

Yep! Once you have the access token you can make any request to the graph API that you have permission for from the user. Just sign the request like you would any other and you're all set!

@calebd calebd closed this as completed May 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants