0

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];



                                                }


                                            }];
    }
}
Madu
  • 4,849
  • 9
  • 44
  • 78
  • How did you open your session ? Are you sure that `[FBSession activeSession]` is set ? – KIDdAe Mar 06 '14 at 14:20
  • i am using FBLoginView – Madu Mar 06 '14 at 16:25
  • The error is telling you that you are asking new permissions before receiving answer for the first call. It seems that you're requesting permissions twice by mistake (testing if session is open won't help you in this case) or you're requesting different permission at the same time but with different calls (you should probably ask all the permissions you want with just 1 call) – KIDdAe Mar 06 '14 at 16:48
  • But in the first call i get the readPermissions and in the second call i get the publishPermission. These two permission can't be granted at the same time and when the user deny the publish permission first time and if i request it again it crashes. – Madu Mar 07 '14 at 09:27

0 Answers0