parse 'pfloginviewcontroller' certain facebook permissions not working in ios

570 views Asked by At

My facebook login with parse is working perfectly with no issues but the access token that is generated is not showing permission for friendlist although I gave that permission at the time of login. I came to know when I used facebook Graph API 'Friendlists'(fbID/friendlists) and the response array is empty. So, also run Graph API explorer with the same access token generated. It does not show me any error and data array is same empty and a debug message with

"The field 'friendlists' is only accessible on the User object after the user grants the 'read_custom_friendlists' permission"

This is the method I am using

WLLoginViewController *login = [[WLLoginViewController alloc]init];
login.fields = PFLogInFieldsFacebook;
NSArray *permission = [[NSArray       alloc]initWithObjects:@"email",@"read_custom_friendlists",@"publish_actions",@"user_location",@"user_hometown",@"user_website",@"user_about_me",@"user_photos",@"user_friends",@"read_custom_friendlists", nil];

login.facebookPermissions = permission;

WLLoginViewController has inherited PFUserLoginManager and I am calling it from some other class.

- (void)logInViewController:(PFLogInViewController *)logInController   didLogInUser:(PFUser *)user {

[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    NSLog(@"permissions%@",logInController.facebookPermissions);
    if(result) {
        if ([result valueForKey:@"hometown"]) {
            NSString *nn = [[result valueForKey:@"hometown"] valueForKey:@"name"];
            [user setValue:[[result valueForKey:@"hometown"] valueForKey:@"name"] forKey:@"hometown"];
        }
        if ([result valueForKey:@"location"]) {
            [user setValue:[[result valueForKey:@"location"] valueForKey:@"name"] forKey:@"location"];
        }
        [user setObject:[result valueForKey:@"id"] forKey:kWLUser_FacebookId];
        [user setObject:[result valueForKey:@"name"] forKey:kWLUser_Name];
        [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
            if([PFInstallation currentInstallation]) {
                // save in background current installation.
                [[PFInstallation currentInstallation] setObject:user forKey:@"user"];
                [[PFInstallation currentInstallation]saveInBackground];
            }
        }];
        [[ParseManager sharedInstance]saveDeviceToken:[[NSUserDefaults standardUserDefaults]objectForKey:@"DeviceToken"]];
        [self dismissViewControllerAnimated:YES completion:nil];
    }else {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Could not login" message:@"Could not login to facebook, please try again" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [alert show];
    }
}];

} This is the method which is which is running when the user return to the app from facebook.The nslog in the code is showing the permission perfectly which I gave.

And finally this is the method for handling facebook request -(void)handleFacebookFriendsRequest {

NSString *queryParams = @"id,name,picture.width(350).height(250),location,hometown,likes.limit(100000),statuses.limit(1),languages";
[queryParams stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",[FBSession activeSession].permissions);
NSLog(@"%@",[[FBSession activeSession].permissions description]);
NSLog(@"%@",[FBSession activeSession].accessTokenData.accessToken);
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"me/friends?fields=%@",queryParams] completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    if (!error) {
        //change For getting everything out
        NSLog(@"%@",[result objectForKey:@"data"]);
        [[ApplicationDataModel sharedInstance]setFacebookFriendsList:[result objectForKey:@"data"]];
        [self facebookRequestDidLoad:result];
    } else {
        [self facebookRequestDidFailWithError:error];
    }

}];
}

enter image description here

I am stuck badly need help. Thanks in advance

1

There are 1 answers

2
codinpora On

The read_custom_friendlists is not a default permission, as a result you have to go through the approval process for this feature (https://developers.facebook.com/docs/facebook-login/permissions/v2.2)

To submit items for approval go to: developers.facebook.com -> My Apps -> Status & Review

Caveat: "People listed in the Roles section of your App Dashboard - including Admins, Developers and Testers - can grant any permission without review. If only people in these Roles will use your app, you don't need to submit it for Login Review."(https://developers.facebook.com/docs/apps/faq)