如何使用facebook登录ios simulaor?

Nir*_*iya 0 iphone facebook login ios

当我尝试登录时,它会显示以下错误:

错误:错误Domain = com.facebook.sdk Code = 2"操作无法完成.(com.facebook.sdk error 2.)"UserInfo = 0xa54db80 {com.facebook.sdk:ErrorLoginFailedReason = com.facebook.sdk :SystemLoginCancelled,com.facebook.sdk:ErrorInnerErrorKey = Error Domain = com.apple.accounts Code = 7"无法完成操作.(com.apple.accounts error 7.)",com.facebook.sdk:ErrorSessionKey =,expirationDate:(null),refreshDate:(null),attemptsRefreshDate:0001-12-30 00:00:00 +0000,permissions:(null)>}

当我从facebook(官方)登录时,这工作正常.提前致谢.

Raj*_*aju 5

这对我有用:

转到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)

//和其他方式.......也尝试........并检查这个......

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