2014-03-04 29 views
0

当我尝试登录,它表明我这个错误:如何使用ios模拟器与facebook登录?

error :Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (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 "The operation couldn’t be completed. (com.apple.accounts error 7.)", com.facebook.sdk:ErrorSessionKey=, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}

;当我从Facebook登录(官方)登录该工作正常。 在此先感谢。

回答

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; 
    } 

//和其他的方式.......尝试ALSO ........然后选中此...

检查你的包标识为您的项目,你给包在developer.facebook.com上创建的应用程序标识符表明它们相同或不相同。

+0

感谢它对我有用....我没有在fecebookApp注册中设置BundleID。 –

相关问题