Facebook iOS登录 - 未调用委托方法(Facebook iOS Login - Delegate methods not being called)
我正在尝试为我的一个应用程序和委托方法实现Facebook登录 -
fbDidLogin:
/application: handleOpenURL:
/fbDidNotLogin:
未被调用。 这是我正在使用的代码。 任何帮助深表感谢!- (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 { }
我还在相应条目下的
info.plist
文件中有Facebook App ID。 我在loginWithFacebook:
方法中有断点,它们成功点击。[facebook authorize:]
方法也会被调用。谢谢,
Teja公司。I'm trying to implement the Facebook login for one of my applications and the delegate methods -
fbDidLogin:
/application: handleOpenURL:
/fbDidNotLogin:
aren't being called. Here is the code that 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 under the appropriate entry. I have break points in theloginWithFacebook:
method and they hit successfully. the[facebook authorize:]
method gets called as well.Thanks,
Teja.
原文:https://stackoverflow.com/questions/6803303