当我的应用程序尝试邀请用户朋友列表中的人时,它会检查活动会话的权限。如果没有找到这两个权限,它会调用 reauthorizeWithPublishPermissions。
有问题的代码如下:
if ([FBSession.activeSession.permissions indexOfObject:@"publish_stream"] == NSNotFound || [FBSession.activeSession.permissions indexOfObject:@"user_photos"] == NSNotFound ) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:YES forKey:@"FacebookLogin"];
[FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObjects:@"publish_stream",@"user_photos", nil]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
if (error)
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Can not get permission"
message:error.localizedFailureReason
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
[defaults setBool:YES forKey:@"FacebookLogin"];
}
else {
if([[SocialNetworkingData getInstance] getFBDisplayType] == 0)
{
[self postFeedWithPermission:friendList];
}
else if ([[SocialNetworkingData getInstance] getFBDisplayType] == 1)
{
[self postPhotoWithPermission:friendList];
}
else if([[SocialNetworkingData getInstance] getFBDisplayType] == 2){
[self postFeedDialog:friendList];
}
}
}];
}
else
{
if([[SocialNetworkingData getInstance] getFBDisplayType] == 0) {
[self postFeedWithPermission:friendList];
}
else if ([[SocialNetworkingData getInstance] getFBDisplayType] == 1) {
[self postPhotoWithPermission:friendList];
}
else if([[SocialNetworkingData getInstance] getFBDisplayType] == 2){
[self postFeedDialog:friendList];
}
}
无论如何,完成处理程序都会收到错误 2。