我正在设置我的应用程序,以便用户可以使用 Facebook 登录。我已经加载了 Facebook SDK,但由于某种原因,当我尝试“登录”到 Facebook 时,我在控制台中收到此错误:
FBSDKLog: Error Domain=com.facebook.sdk Code=5 "操作无法完成。(com.facebook.sdk 错误 5.)" UserInfo=0x10906da90 {com.facebook.sdk:HTTPStatusCode=400, com.facebook .sdk:ErrorSessionKey=,过期日期:2014-01-02 03:26:48 +0000,刷新日期:2013-11-03 06:19:26 +0000,尝试刷新日期:0001-12-30 00:00:00 +0000 , 权限。
有谁知道为什么?看看下面的代码。我觉得这与我的 ShowLoginView 方法有关(我试图在现有 Storyboard 之上打开 SSLloginViewcontroller Xib)。在我开始使用这种方法之前,我能够很好地登录 Facebook……帮助 :)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.mainViewController = [[SSViewController alloc]
initWithNibName:@"SSViewController" bundle:nil];
self.navController = [[UINavigationController alloc]
initWithRootViewController:self.mainViewController];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// Yes, so just open the session (this won't display any UX).
[self openSession];
} else {
// No, display the login page.
[self showLoginView];
}
return YES;
}
- (void)showLoginView
{
UIViewController *topViewController = [self.navController topViewController];
UIViewController *modalViewController = [topViewController modalViewController];
// If the login screen is not already displayed, display it. If the login screen is
// displayed, then getting back here means the login in progress did not successfully
// complete. In that case, notify the login view so it can update its UI appropriately.
if (![modalViewController isKindOfClass:[SSLoginViewController class]]) {
SSLoginViewController* loginViewController = [[SSLoginViewController alloc]
initWithNibName:@"SSLoginViewController"
bundle:nil];
[topViewController presentViewController:loginViewController animated:NO completion:nil];
} else {
SSLoginViewController* loginViewController =
(SSLoginViewController*)modalViewController;
[loginViewController loginFailed];
}
}