无法验证Facebook publish_actions权限

时间:2015-03-06 17:50:22

标签: ios iphone facebook facebook-graph-api

我已成功登录Facebook并要求获得publish_actions权限。该权限已授予,因为我可以在https://www.facebook.com/settings?tab=applications上以及通过调用

轻松验证
-(void) whatPermissionsDoIHave
{
  [FBRequestConnection startWithGraphPath:@"/me/permissions"
    completionHandler:^(
      FBRequestConnection *connection,
      NSDictionary* result,
      NSError *error
    ) {
       //do checks in here
      }
  }];
}

所以我肯定知道我有许可。但是,无论何时分享,我的权限检查都会返回false。我现在将展示我的许可检查

+ (BOOL)hasWritePermissions
{
    if (!FBSession.activeSession.isOpen) return NO;
    NSLog(@"So the session is at least open");
    return [FBSession.activeSession.permissions indexOfObject:@[@"publish_actions"]] != NSNotFound;
}

所以我错过了别的什么?也许我应该在AppDelegate中做过这样的事情?感谢您的任何见解。

现在,我在AppDelegate中进行的唯一通话是

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    // attempt to extract a token from the url
    return [FBAppCall handleOpenURL:url
                  sourceApplication:sourceApplication
                    fallbackHandler:^(FBAppCall *call) {
                        NSLog(@"In fallback handler");
                    }];
}

1 个答案:

答案 0 :(得分:1)

permissions属性是一个字符串数组,但是你要在另一个数组上调用indexOfObject,这可能是它无法找到它的原因。试试这个:

return [FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound;