Reputation: 1268
I am using FB SDK v4.4 (latest) and think I have avoided the gotchas in the other questions.
I am establishing a logIn:
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"]
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
} else {
[self facebookGetUserProfileWithCompletion:completion];
}
}];
I've specifically asked for "email" (an extended permission that requires app review).
My app has passed review, and the user gives permission for email when prompted. Adding a [result.grantedPermissions containsObject:@"email"]
check in the handler returns TRUE.
Once the user's has responded to the UI, the code then gets the user profile from 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 have just five parameters; I am missing email. Using Graph API Explorer, I get the full six. The user does have an email address registered with FB.
Why no email???!!!
Upvotes: 3
Views: 5263
Reputation: 1268
I've pretty much resolved my issues. Here they are:
1) @cbroe had the most helpful suggestion of getting the token and using Graph API Explorer to debug. Lots of help there.
2) FB are shifting their DOB field to age_range in most cases. It seems that my existing app will still return DOB, but the new version will not without permission. No doc on this I could find, but if I go with age_range, I'm good.
3) There was a strange problem with my email address in my FB test account. That's fixed, and I am getting email again no problem. Again, the Graph API test was most helpful in resolving this. Thanks again @cbroe!
Upvotes: 3
Reputation: 6790
Your parameters should be just one string
@"fields:id,email,first_name,last_name,link,locale"
Upvotes: 0