ios - Rerequesting the Publish Permission -
i have problem when re- request publish permission (manage_notifications
) after getting readpermission.
the use case if read permission asks user authorize manage_notifications
permission if user don't allow , try again next time app crashes saying
terminating app due uncaught exception 'com.facebook.sdk:invalidoperationexception', reason: 'fbsession: not valid reauthorize while previous reauthorize call has not yet completed.'
i checking fbsession open before requesting publish permissions.
below code
if([[fbsession activesession] isopen] ){ if ([fbsession.activesession.permissions indexofobject:@"manage_notifications"] == nsnotfound) { // if don't have permission, request [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 permission notifications."; } if([fberrorutility errorcategoryforerror:error ] == fberrorcategorypermissions){ mytitle = @"permission denied"; body = @"unable permission notifications."; }else { mytitle = @"permission error"; body = @"unable permission notifications."; } uialertview *alertview = [[uialertview alloc] initwithtitle:mytitle message:body delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertview show]; } }]; } }
Comments
Post a Comment