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
Another potential cause for this error: Attempting to get permission for a Facebook app in sandbox mode when the Facebook user is not listed in the app's admins, developers or testers.
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.
This worked for me:
This could happen on any device, therefore in your app you will have to make sure to handle this error correctly. I reckon you give the user feedback why Login With Facebook failed and ask the user to check their Facebook settings on their device.
- (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;
}
I had a similar issue. the error comes up when the i switched the fb user from setting. Facebook authorization fails on iOS6 when switching FB account on device This solved my problem
I solve my problem by passing nil permission while login.
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
For me the problem was invalid permissions - I was requesting "birthday" instead of "user_birthday". It's a shame the error message isn't at least minimally descriptive - just saying "permissions invalid" rather than ERROR CODE 2 would have saved me so much time.