I just found this problem while testing my application and it really starts to annoy me. So what the environment looks like:
- Facebook application not installed.
- The user is registered in the iOS system account (in the settings → Facebook)
When my application tries to authenticate a user for the first time, it provides this wall of text: (I tried to clear it a bit)
2014-01-30 15:20:31.439 Unifeed[2140:70b] Session is <FBSession: 0xb74f9e0, state:
FBSessionStateClosedLoginFailed,
loginHandler: 0x0, appID: *************, urlSchemeSuffix: ,
tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0xb73bd90>,
expirationDate: (null),
refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>
2014-01-30 15:20:31.440 Unifeed[2140:70b] Session closed
2014-01-30 15:20:31.440 Unifeed[2140:70b] User logged out
2014-01-30 15:20:31.441 Unifeed[2140:70b] Error occured Error Domain=com.facebook.sdk Code=2
"The operation couldn’t be completed. (com.facebook.sdk error 2.)"
UserInfo=********
{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: 0xb74f9e0, state: FBSessionStateClosedLoginFailed,
loginHandler: 0x0, appID: ************, urlSchemeSuffix:
, tokenCachingStrategy:<FBSessionTokenCachingStrategy:
0xb73bd90>, expirationDate: (null), refreshDate: (null),
attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}
2014-01-30 15:20:31.441 Unifeed[2140:70b] User cancelled login
2014-01-30 15:20:31.445 Unifeed[2140:70b] User logged out
, , , , , . , , , ... Facebook , ... , , App, FB, .... - ?
: ( FB)
- (void) facebookSessionChange {
if (FBSession.activeSession.state == FBSessionStateOpen
|| FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {
[FBSession.activeSession closeAndClearTokenInformation];
} else {
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
}
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
NSLog(@"Session is %@", session);
if (!error && state == FBSessionStateOpen){
NSLog(@"Session opened");
[self userLoggedIn];
return;
}
if (state == FBSessionStateClosed || state == FBSessionStateClosedLoginFailed){
NSLog(@"Session closed");
[self userLoggedOut];
}
if (error){
NSLog(@"Error occured %@", error);
if ([FBErrorUtility shouldNotifyUserForError:error] == YES){
NSLog(@"Error occured %@", error);
} else {
if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryUserCancelled) {
NSLog(@"User cancelled login");
} else if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryAuthenticationReopenSession){
NSLog(@"Session is no longer valid");
} else {
NSDictionary *errorInformation = [[[error.userInfo objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"] objectForKey:@"body"] objectForKey:@"error"];
NSLog(@"Error occured : %@", [errorInformation objectForKey:@"message"]);
}
}
[FBSession.activeSession closeAndClearTokenInformation];
[self userLoggedOut];
}
}
- (void)userLoggedOut
{
NSLog(@"User logged out");
}
- (void)userLoggedIn
{
NSLog(@"User Logged in");
[_delegate doneLogginginToFb];
}
, ... ?