0

您好,我正在使用 FBSession 打开登录视图,它打开 Safari 以在 iOS5.0 和 ios 6.0 模拟器中登录,但在 ios 6.0 iPhone 中打开 Facebook APP 而不是 safari。请告诉我是什么原因,我该如何解决?这里是我的 Facebook 登录代码。

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    return [FBSession openActiveSessionWithReadPermissions:nil
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session,
                                                             FBSessionState state,
                                                             NSError *error) {
                                             [self sessionStateChanged:session
                                                                 state:state
                                                                 error:error];
                                         }];
}

/*
 * Callback for session changes.
 */
- (void)sessionStateChanged:(FBSession *)session
                      state:(FBSessionState) state
                      error:(NSError *)error
{
    switch (state) {
        case FBSessionStateOpen:
            if (!error) {
                // We have a valid session
                NSLog(@"User session found");

                if ([[IntegrationManager sharedInstance] facebookDidLogin:nil]) {
                    [self.window.rootViewController dismissModalViewControllerAnimated:YES];
                };

            }
            break;
        case FBSessionStateClosed:NSLog(@"Fbsession close");
        case FBSessionStateClosedLoginFailed:
            [FBSession.activeSession closeAndClearTokenInformation];
            break;
        default:
            break;
    }

    [[NSNotificationCenter defaultCenter]
     postNotificationName:FBSessionStateChangedNotification
     object:session];

    if (error) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Error"
                                  message:error.localizedDescription
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}
4

1 回答 1

0

为方便用户,启动 facebook 应用程序而不是打开网站。这样做是为了让用户不必再次登录,也称为单点登录。

如果您使用的是 Facebook iOS SDK,则您无能为力,也不应该对此做任何事情。

于 2012-12-18T11:47:18.013 回答