FBSDKLoginManager logInWithReadPermissions?

Omarj picture Omarj · Mar 31, 2015 · Viewed 30.4k times · Source

I'm using FBSDKLoginButton to allow to user login using Facebook and using FBSDKLoginButton.readPermissions = @[@"public_profile",@"email",@"user_likes",@"email",@"user_birthday"];

to ask for permissions , but I need one more permission which is publish_actions I should use FBSDKLoginManager

with

 logInWithReadPermissions:@[@"public_profile",@"user_likes",@"user_birthday"] 
logInWithPublishPermissions:@[@"publish_actions"]

but this for some reason affect on my permission "some of my permission are missing check image

Code:-

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
                [login logInWithPublishPermissions:@[@"publish_actions"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
                    if (error) {
                        // Process error
                    } else if (result.isCancelled) {
                        // Handle cancellations
                    } else {
                        // If you ask for multiple permissions at once, you
                        // should check if specific permissions missing
                        if ([result.grantedPermissions containsObject:@"publish_actions"]) {
                            // Do work
                        }
                    }
                }];

[login logInWithReadPermissions:@[@"public_profile",@"",@"user_likes",@"user_birthday"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if (error) {
        // Process error
    } else if (result.isCancelled) {
        // Handle cancellations
    } else {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if ([result.grantedPermissions containsObject:@"email"]) {
            // Do work
        }
    }
}];

Result:-

**it take long time to redirect the user to the permission view ? and not all my permission appear to user **

enter image description here

Note:- I know that warning mean that i need to submit my app to review but this not what i'm asking about right now .

Update

When I Tried "Dheeraj Singh" solution but in this case user will be re-direct twice to the Facebook first time to get publish_action then to get email and birthday permission which is bad.

Answer

Dheeraj Singh picture Dheeraj Singh · Mar 31, 2015

Facebook Login provides your app access to a person's public profile, friend list, and email address. These three permissions do not require review. Instead, your app's users will choose whether they want to grant access to this information.

In order for your app to access additional elements of a person's Facebook profile (read permissions) or to publish content to Facebook on their behalf (write permissions), you will need to submit for review.

Refer to : https://developers.facebook.com/docs/apps/review#submitlogin

Updated :

Apps should separate the request of read and publish permissions.

 FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

    [login logInWithPublishPermissions:@[@"publish_actions"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if (error) {
            // Process error
        } else if (result.isCancelled) {
            // Handle cancellations
        } else {
            // If you ask for multiple permissions at once, you
            // should check if specific permissions missing
            if ([result.grantedPermissions containsObject:@"publish_actions"]) {
                // Do work

                [login logInWithReadPermissions:@[@"user_likes",@"user_birthday"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
                    if (error) {
                        // Process error
                    } else if (result.isCancelled) {
                        // Handle cancellations
                    } else {
                        // If you ask for multiple permissions at once, you
                        // should check if specific permissions missing
                        if ([result.grantedPermissions containsObject:@"user_birthday"]) {
                            // Do work

                            NSLog(@"Permission  2: %@",result.grantedPermissions);
                        }
                    }
                }];

            }
        }
    }];

You don't need public_profile in read permission as if granted permission to publish_actions it also gets permission for public_profile.