I'm trying to log into facebook from an iPhone app but everytime I try running the app it gives me a The operation could not be completed (com.facebook.sdk error 2)
.
I have tried a ton of stuff, resyncing the facebook account of the device (like suggested here , trying it on the iOS simulator and then actually plugging in an iPhone and running it on that.
Nothing is removing this ambiguous error. I'm not sure what I'm supposed to do from here.
This is my method:
-(BOOL)login {
if (FBSession.activeSession.isOpen) {
NSLog(@"already logged in");
return true;
} else {
NSLog(@"Need to login");
[FBSession.activeSession closeAndClearTokenInformation];
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", @"birthday", nil];
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
// if login fails for any reason, we alert
if (error) {
NSLog(@"Just errored %@", error.localizedDescription);
} else if (FB_ISSESSIONOPENWITHSTATE(status)) {
// send requests if we successfully logged in
NSLog(@"FBSessionOpenWithstate");
}
}];
return false;
}
}
It always first returns a false, then it logs "Just errored The operation couldn’t be completed. (com.facebook.sdk error 2.)"
Configure the plist from the guide facebook has here https://developers.facebook.com/docs/ios/getting-started/
It should work if you have the plist and an app on the facebook developer profile with iOS enabled