我在获取readPermission后重新请求发布权限(manage_notifications
)时遇到了一些问题。
用例就像是,如果我获得了读取权限,那么它会要求用户授权manage_notifications
权限,然后如果用户不允许它,我会在下次我的应用程序崩溃时再次尝试
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.'
我在请求发布权限之前检查FBSession已打开。
以下是我的代码
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];
}
}];
}
}