I try to fetch at least id, username and email from a logged in Facebook user. I first login using the permission type: Email. And if succeeded try to fetch an FBSDKGraphRequest, which returns every possible value but email.
I tried adding permissions like public_profile as well, but in any case I try, I do not get email. I looked in the developers dashboard, and email seems to be approved by default.
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
} else if (result.isCancelled) {
return;
}
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, gender, first_name, last_name, locale, email"}];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
}
NSLog(@"Fetched user: %@", result);
}];
}];
I just had the same problem and I was lucky enough to find the solution in the comment. It is given by CBroe. I think that this should be posted as an answer.
So... in my case the problem was that the user had not confirmed his email. Once I've confirmed it I received the email from Facebook. All the acknowledgemnts are to CBroe