简体   繁体   English

Facebook SDK 4.x权限问题iOS

[英]Facebook SDK 4.x Permission issue iOS

I am trying to get Feed for logged in user's timeline. 我正在尝试为登录用户的时间线获取Feed I have a login button, to which I am passing read permissions including user_posts . 我有一个登录按钮,我通过读取权限包括user_posts Amazingly, Facebook does not grant me this permission and ignores it. 令人惊讶的是,Facebook没有授予我这个许可,而忽略了它。

Code: 码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends", @"user_posts"];

    self.loginButton.delegate = self;

    if([FBSDKAccessToken currentAccessToken])
    {
        NSLog(@"Have access token");
        NSLog(@"permissions .... %@",[FBSDKAccessToken currentAccessToken].permissions);
        [self retrieveFeed];
    }

}

#pragma mark - Login Delegate

-(void) loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
    NSLog(@"Login Successfully!!");
    NSLog(@"permissions .... %@",[FBSDKAccessToken currentAccessToken].permissions);

    [self retrieveFeed];

}

-(void) loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{

}

#pragma mark - Receive FB Feed

-(void) retrieveFeed
{       
    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/feed" parameters:nil];

    FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
    [connection addRequest:request completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

        NSLog(@"%@",result);

        if(error)
            NSLog(@"Some error FEED;;;;;; %@",error.localizedDescription);
    }];
    [connection start];
}

On Clicking login Button, I get following permissions screen. 在单击登录按钮上,我获得以下权限屏幕。 Facebook has ignored user_posts permission. Facebook忽略了user_posts权限。

在此输入图像描述

Even if I try to get this permission later after login, Facebook tells me that I have already authorized app to do so , even when there is no such permission granted! 即使我在登录后尝试获得此许可,Facebook也告诉我, 我已经授权应用程序这样做 ,即使没有授予此类许可! The code for getting new permission is: 获得新权限的代码是:

-(void) checkForFeedPermission
{
    if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"user_posts"]) {

        NSLog(@"already granted feed access");
          [self retrieveFeed];

    } else {
        FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
        [loginManager logInWithReadPermissions:@[@"user_posts"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {

            NSLog(@"requesting feed access");
             [self retrieveFeed];

        }];
    }
}

I have been banging my head on this issue for three days. 我已经在这个问题上敲了三天。 Please suggest me where can I be wrong? 请建议我哪里可以出错? Thanks. 谢谢。

I think that not working for grant user_posts as par Facebook developer documentation for permission you have to submit your Facebook app for review see i attach screenshot that clearly said. 我认为不适用于授予user_posts作为Facebook开发者文档的权限,你必须提交你的Facebook应用程序进行审查,请参阅我附上的截图,清楚地说。

在此输入图像描述

So you have to submit your facebook app for login review might be then you can able to set this permission at loginTime 因此,您必须提交您的Facebook应用程序进行登录审核,然后您才能在loginTime设置此权限

If you are in development mode and not yet ready to publish the app for facebook review then the best way to do what you want is to use Test Users. 如果您处于开发模式但尚未准备好发布应用以进行Facebook审核,那么最好的方法就是使用测试用户。 In your facebook app dashboard go to Roles and create some test users. 在您的Facebook应用程序仪表板中,转到角色并创建一些测试用户。 Note that its a separate tab and not Testers in the first tab. 请注意,它是一个单独的选项卡,而不是第一个选项卡中的Testers。 When you create test users you can by default assign what permissions should be assigned to that user. 创建测试用户时,您可以默认分配应为该用户分配的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM