IOS Facebook SDK: FBSDKGraphRequest does not receive email despite permission

I am using FB SDK v4.4 (latest) and think I have avoided gotchas in other questions.

I am setting logIn:

       FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
       [login logInWithReadPermissions:@[@"email"] 
           handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
           if (error) {
              // Process error
           } else {
              [self facebookGetUserProfileWithCompletion:completion];
           }
       }];

      

I specifically asked for "email" (extended permission that requires viewing the app).

My app passed validation and the user grants permission to send email when prompted. Adding a check [result.grantedPermissions containsObject:@"email"]

in the handler returns TRUE.

After the user has responded to the UI, the code then gets the user profile from the Graph API:

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields" : @"id,email,first_name,last_name,link,locale"}]  
              startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

if (!error) {
     NSString *email = [result objectForKey:@"email"] ;
     NSString *first_name = [result objectForKey:@"first_name"] ;
     //etc...
}

      

At this point, I only have five parameters; I am missing email. Using the Graph API Explorer I get the full six. The user has an email address registered with FB.

Why is there no email ??? !!!

+3


source to share


2 answers


I solved my problems a lot. Here they are:

1) @cbroe provided the most helpful suggestion to get the token and use the Graph API Explorer for debugging. There's a lot of help out there.



2) FBs in most cases offset their DOB field in age_range. It seems that my existing application will still return a DOB, but the new version will be without permission. I couldn't find any document about this, but if I go with age_range I'm fine.

3) My test FB account has a weird problem with my email address. This has been fixed and I receive email again with no problem. Again, the Graph API benchmark was most helpful in solving this problem. Thanks again @cbroe!

+3


source


Your parameters should only be one line



@"fields:id,email,first_name,last_name,link,locale"

      

0


source







All Articles