我正在运行以下代码来登录facebook:
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile, email, user_friends"]
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
NSLog(@"fb token: %@", session.accessTokenData.accessToken);
if(error) {
NSLog(@"error: %@", error);
}
}];
当iOS没有Facebook帐户时,它可以正常工作。但是,如果帐户绑定到系统,则会导致此错误:
fb token: (null)
error: Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x10eb2b5c0 {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=<FBSession: 0x10ec879b0, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: 448248105305258, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x10eb2ab80>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}
2014-07-03 21:40:53.410 Tag Beta copy[62878:60b]
应用程序ID位于Facebook帐户的设置页面中,而Facebook帐户未处于沙盒模式。这是facebook帐户的屏幕截图:
非常感谢您解决此错误的任何帮助!