I am have some problem when i re- request the publish permission (manage_notifications
) after getting the readPermission.
The use case is like that if i get the read permission then it asks user to authorize for the manage_notifications
permission then if the user don't allow it and i try it again the next time my app crashes saying that
Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: It is not valid to reauthorize while a previous reauthorize call has not yet completed.'
I am checking the FBSession open before requesting the publish permissions.
Below is my code
if([[FBSession activeSession] isOpen] ){
if ([FBSession.activeSession.permissions indexOfObject:@"manage_notifications"] == NSNotFound) {
// if we don't already have the permission, then we request it now
[FBSession.activeSession requestNewPublishPermissions:@[@"manage_notifications"]
defaultAudience:FBSessionDefaultAudienceOnlyMe
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
ALog(@"Requesting new permission");
} else{
NSString *mytitle = @"";
NSString *body = @"";
if ( [FBErrorUtility errorCategoryForError:error ] == FBErrorCategoryUserCancelled) {
mytitle = @"Permission denied";
body = @"Unable to get permission for Notifications.";
} if([FBErrorUtility errorCategoryForError:error ] == FBErrorCategoryPermissions){
mytitle = @"Permission denied";
body = @"Unable to get permission for Notifications.";
}else {
mytitle = @"Permission Error";
body = @"Unable to get permission for Notifications.";
}
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:mytitle
message:body
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}];
}
}