首页 文章

Facebook登录失败,在iOS 6上失败

提问于
浏览
2

当我尝试使用Facebook iOS SDK登录时,我收到错误操作无法完成(com.facebook.sdk错误2) .

会话的状态是:FBSessionStateClosedLoginFailed .

这是我的代码:

-(void) callFBService{

    NSArray *permissions = [[NSArray alloc] initWithObjects:@"email, publish_stream, user_likes, friends_likes", nil];
    [FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES
                              completionHandler:^(FBSession *fbsession,
                                                  FBSessionState status,
                                                  NSError *error) {
          if(error)
          {
              NSLog(@"Session error");
              [self fbResync];
              [NSThread sleepForTimeInterval:0.5];   //half a second
              [FBSession openActiveSessionWithReadPermissions:permissions
                                                 allowLoginUI:YES
                                            completionHandler:^(FBSession *fbsession, FBSessionState status, NSError *error) {
                                                [self sessionStateChanged:fbsession state:status error:error];
                                            }];

          }
          else
              [self sessionStateChanged:fbsession state:status error:error];

     }];
}

我已尝试过以下帖子中的所有内容:

The operation couldn’t be completed. (com.facebook.sdk error 2.) ios6 Facebook Registration : The operation couldn't be completed (com.facebook.sdk error 2) Facebook SDK 3.1 iOS: Handle login if user remove app from Facebook Settings

有任何想法吗???请!

1 回答

  • 2

    您正在使用读取权限传递 publish_stream ,但 publish_stream 是写入权限 . 它也被弃用(改为使用 publish_actions ) . 尝试删除该权限 . 在您的用户使用读取权限登录后,您需要单独请求该权限 . 请参阅SDK文档:https://developers.facebook.com/docs/technical-guides/iossdk/login/#read

    此外,还有一些事项要检查:确保Facebook.com上的应用程序配置正确,包括捆绑包ID . 确保您尝试登录的用户拥有该应用程序的权限(如果该应用程序处于沙盒模式,请确保将该用户添加为测试人员并已批准此用户) .

相关问题