The operation couldn’t be completed. (com.facebook

2019-01-07 13:48发布

Hi i am ussing ios6 for facebook login and i am getting this error as native popup

The operation couldn’t be completed. (com.facebook.sdk error 2.)

This is the scenario ive used. (I am running this on simularor)

I have logged in to the facebook app through settings and i tried to login to my app and its working fine.

Then i logged out of the facebook from settings and logged in again with different user. Then i tried to login to the app. I am getting this error.

I tried loging out of the app using the command

[FBSession.activeSession closeAndClearTokenInformation];

But no use.

The bundle identifier in the facebook app is same as in my ios app.

this is the code i used to login

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
    [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session,
       FBSessionState state, NSError *error) {
         [self sessionStateChanged:session state:state error:error];
     }];

Any help is appreciated.

This is the error i am getting

Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x9535330 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:SystemLoginDisallowedWithoutError, com.facebook.sdk:ErrorSessionKey=, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}

NOTE I got the same error on a different occation. At that time it was a bug in my code

Instead of giving permission as

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email",@"birthday", nil];

i was wrongly doing it as

NSArray *permissions = [[NSArray alloc] initWithObjects:@"email,birthday", nil];

SOLUTION Even after correcting the code, I was getting the same error. I have to logout and login the facebook from ios settings screen. Once i did that the correct code never caused any problem. Note that the problem only occured on the device that previously executed the buggy code. Note sure what caused the problem, Hope this info helps someone

7条回答
ゆ 、 Hurt°
2楼-- · 2019-01-07 14:28

I had the same issue and took a whole day to figure out the problem. This error message by Facebook SDK is very vague. I had this problem due to openURL: method being overwritten in MyApplication. I removed the overwritten method and facebook login worked fine.

查看更多
登录 后发表回答