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
source share