I am trying to get work permissions from a user using the Facebook SDK on iOS.
I call the code below in the method, which is called if the application does not have the necessary permissions to publish for publication on the users facebook wall.
// No permissions found in session, ask for it [FBSession.activeSession requestNewPublishPermissions: [NSArray arrayWithObject:@"publish_actions"] defaultAudience: FBSessionDefaultAudienceEveryone completionHandler: ^(FBSession *session, NSError *error) { if( !error ) { // Do something } }];
The first time this code is called, the user goes to the permissions page, and before he even switches to safari on the device, the block is called and this error message is returned
Error Domain=com.facebook.sdk Code=2 "The operation couldn't be completed. (com.facebook.sdk error 2.)" UserInfo=0xc426410 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorReauthorizeFailedReasonUserCancelled,
Then the application continues to display the permissions page in safari, where the user selects ok. He then returns to the application. Permissions were not installed at this point, even if the user was granted the permissions page and accepted.
When you try to send a second time, the user goes to the permissions page in safari, and the requestNewPublishPermissions method is not interrupted instantly. The user selects ok, and then everything works as expected.
Thus, only for the first time, when calling the NewPublishPermissions request, he was not able to instantly return the ErrorReauthorizeFailedReasonUserCancelled error.
This happens in the simulator and on the device.
Any idea what could be causing this?