Facebook iOS Login - delegate methods not called

I am trying to implement Facebook login for one of my applications, and the delegate methods - fbDidLogin: / application: handleOpenURL: / fbDidNotLogin: not called. Here is the code I'm using. Any help is much appreciated!

 - (void)viewDidLoad { ... facebook = [[Facebook alloc] initWithAppId:kFacebookAppId]; } -(IBAction) loginWithFacebook:(id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; } if (![facebook isSessionValid]) { NSArray* permissions = [[NSArray arrayWithObjects: @"email", nil] retain]; [facebook authorize:permissions delegate:self]; } } #pragma mark - Facebook delegate - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [facebook handleOpenURL:url]; } - (void)fbDidLogin { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"]; [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"]; [defaults synchronize]; } -(void) fbDidNotLogin:(BOOL)cancelled { } -(void) fbDidLogout { } 

I also have the Facebook app id in the info.plist file in the corresponding entry. I have breakpoints in the loginWithFacebook: method and they hit successfully. The [facebook authorize:] method is called.

Thanks,
Thea

+4
source share
2 answers

Unfortunately, I just realized that the application: handleOpenURL: method is an iOS application delegation method. I had it in one of my UIViewControllers. Moved it to the right place, and it works.

+7
source

application: handleOpenURL: calls, and also does not call delegate methods. what should be the problem?

0
source

All Articles