I just upgraded my objective-C code to the newest Facebook SDK 4.0.1 and I can't really understand what am I missing in my login sequence. I followed exactly the guide and the login does work for me but my only problem is that I'm not sure how can I react to the login.
So what I'm trying to do is that as soon as the Facebook login succeeded I would like to fetch his details, now for some reason I can't find out how to do it.
I read that I should put the following code in my viewDidLoad:
if ([FBSDKAccessToken currentAccessToken]) {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"fetched user:%@", result);
}
}];
}
But this code is never being executed when the Facebook login finishes successfully.
When I used to work with the FBLoginView I used the below code in order to get the user details:
- (void)loginViewFetchedUserInfo:(FBSDKLoginManager *)loginView
user:(FBSDKProfile*)user {
NSLog(@"User Details");}
Is there any equivalent function that I can use with the new SDK ?
Thanks for helping !
Edit :
I rezlied I can use the function :
- (void) loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error{
NSLog(@"LOGGED IN TO FACEBOOK");
}
But I think I should also add a delegate to my controller and I'm not sure how.. any help on this one? Am I in the right direction?
Thanks again !