该操作无法完成.(com.facebook.sdk错误2.)ios6

M S*_*M S 22 facebook ios facebook-login ios6

嗨,我正在使用ios6 for facebook登录,我收到此错误作为本机弹出窗口

该操作无法完成.(com.facebook.sdk错误2.)

这是我使用过的场景.(我在simularor上运行它)

我已通过设置登录到Facebook应用程序,我尝试登录到我的应用程序,其工作正常.

然后我从设置中退出Facebook并再次使用不同的用户登录.然后我尝试登录该应用程序.我收到了这个错误.

我尝试使用该命令退出应用程序

[FBSession.activeSession closeAndClearTokenInformation];

但没用.

Facebook应用程序中的包标识符与我的ios应用程序中的相同.

这是我用来登录的代码

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
    [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session,
       FBSessionState state, NSError *error) {
         [self sessionStateChanged:session state:state error:error];
     }];
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.

这是我得到的错误

Domain = com.facebook.sdk Code = 2"操作无法完成.(com.facebook.sdk error 2.)"UserInfo = 0x9535330 {com.facebook.sdk:ErrorLoginFailedReason = com.facebook.sdk:SystemLoginDisallowedWithoutError, com.facebook.sdk:ErrorSessionKey =,expirationDate:(null),refreshDate:(null),attemptsRefreshDate:0001-12-30 00:00:00 +0000,permissions:(null)>}

注意 我在不同的视频上得到了相同的错误.那时我的代码中有一个错误

而不是给予许可

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email",@"birthday", nil];

我做错了

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email,birthday", nil];

解决方案 即使在纠正代码后,我也遇到了同样的错误.我必须从ios设置屏幕注销并登录facebook.一旦我这样做,正确的代码从未引起任何问题.请注意,问题仅发生在先前执行错误代码的设备上.请注意确定导致问题的原因,希望此信息有助于某人

Boc*_*ica 23

这对我有用:

  • 转到iPhone的设置应用程序.
  • 打开您的Facebook设置
  • 向下滚动到您的应用,确保您的应用允许Facebook互动.

这可能发生在任何设备上,因此在您的应用程序中,您必须确保正确处理此错误.我估计你向用户提供反馈为何登录Facebook失败并要求用户在他们的设备上检查他们的Facebook设置.

 - (void)facebookSessionStateChanged:(FBSession *)session state:(FBSessionState)state error:(NSError *)error
{
    switch (state) {
        case FBSessionStateOpen:
            // handle successful login here
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
            [FBSession.activeSession closeAndClearTokenInformation];

            if (error) {
                // handle error here, for example by showing an alert to the user
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not login with Facebook"
                                                                message:@"Facebook login failed. Please check your Facebook settings on your phone."
                                                               delegate:nil
                                                      cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
                [alert show];
            }
            break;
        default:
            break;
    }
Run Code Online (Sandbox Code Playgroud)


Sum*_*dra 9

检查项目的Bundle标识符,并为您的应用程序提供Bundle标识符,该标识符在developer.facebook.com上创建,它们是否相同.


nep*_*tes 8

导致此错误的另一个可能原因:当Facebook用户未在应用程序的管理员,开发人员或测试人员中列出时,尝试以沙盒模式获取Facebook应用程序的权限.