Facebook 登录清单:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [FBSession.activeSession handleOpenURL:url];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// We need to properly handle activation of the application with regards to SSO
// (e.g., returning from iOS 6.0 authorization dialog or from fast app switching).
[FBSession.activeSession handleDidBecomeActive];
}
- (void)applicationWillTerminate:(UIApplication *)application {
// if the app is going away, we close the session object; this is a good idea because
// things may be hanging off the session, that need releasing (completion block, etc.) and
// other components in the app may be awaiting close notification in order to do cleanup
[FBSession.activeSession close];
}
在我的 sessionStateChanged 中:我正在这样做
switch ( state ) {
case FBSessionStateOpen:
[[Facebook _instance] fbDialogLogin:session.accessToken expirationDate:session.expirationDate];
break;
case FBSessionStateClosed:
[FBSession.activeSession closeAndClearTokenInformation];
break;
case FBSessionStateClosedLoginFailed:
break;
default:
NSLog(@"FBSessionStateUnknown: %d", state);
break;
}
并且不要忘记确保您的 FacebookAppID 和 BundleID 与您在 Facebook Developer Dashboard 中创建的相同!