“[[FBSDKAccessToken currentAccessToken] hasGranted:@”publish_actions“]”总是返回false

时间:2015-05-09 17:36:54

标签: ios objective-c parse-platform facebook-sdk-4.0 facebook-permissions

我正在尝试验证我是否拥有publish_actions权限。总是假的。即使我请求并获得publish_actions并获得succeeded=TRUE,重新验证仍会返回false。

有什么想法吗?

bool bGranted_publish_actions=[[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"];

bool bGranted_user_photos=[[FBSDKAccessToken currentAccessToken] hasGranted:@"user_photos"];

if (!bGranted_user_photos || !bGranted_publish_actions ){
    [PFFacebookUtils linkUserInBackground:[PFUser currentUser] withPublishPermissions:@[@"publish_actions"] block:^(BOOL succeeded, NSError *error) {

        if (succeeded) {
            bool bGranted_publish_actionsV2=[[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"];

2 个答案:

答案 0 :(得分:2)

解决了Parse sdk版本1.7.3。

答案 1 :(得分:0)

Franck在上面的评论中提供的链接显示这是一个Facebook Bug。必须等待下一个版本。

与此同时,这是一个解决方法。

解决方法

在当前访问令牌上调用refresh后保留一组权限。您可以将它们保存在AppDelegate或仅在处理Facebook的类中。

[FBSDKAccessToken refreshCurrentAccessToken:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
        NSDictionary *resultDictionary = (NSDictionary *) result;
        NSArray *permissionsArray= [resultDictionary objectForKey:@"data"];
        NSMutableSet *permissionsSet = [NSMutableSet new];

        for (NSDictionary *permissionDic in permissionsArray) {
            if ([[permissionDic objectForKey:@"status"] caseInsensitiveCompare:@"granted"] == NSOrderedSame) {
                [permissionsSet addObject:[permissionDic objectForKey:@"permission"]];
            }
        }
        blockSelf.permissions = permissionsSet;
    }];

注意 - blockSelf.permissions是调用刷新对象的NSSet属性。