I am developing the application which allow user to login via Facebook (using Facebook SDK for it). The error appears when a user has already logged in Facebook in iPhone settings. If not - all work correctly.
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self fbSessionStateChanged:session state:state error:error];
}];
I've already tried to set permissions as nil array - nothing changed.
The log is:
Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed.
(com.facebook.sdk error 2.)" UserInfo=0x1552c6c0
{com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:SystemLoginDisallowedWithoutError,
com.facebook.sdk:ErrorSessionKey=<FBSession: 0xabe8100, state: FBSessionStateClosedLoginFailed,
loginHandler: 0x0, appID: APPIDHERE, urlSchemeSuffix: ,
tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x14b8f3d0>,
expirationDate: (null), refreshDate: (null),
attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}
Sometimes the error with Code 7 is appears too. I have read almost all topics related to this error.
My steps were:
- Compare my app id in .plist file with FB bundle id. They are the same!!!
- My app is not in a sandbox mode!
- If I change from
[FBSession openActiveSessionWithReadPermissions:permissions
to [FBSession openActiveSessionWithPermissions:permissions
- it works. But it is deprecated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…