Dennis
Dennis

Reputation: 2221

not getting facebook user email despite correct permission

I have a facebook login in my app (SDK 3.5) and want to get the user's email. This is my 'core' login code, where I believe I am setting the correct permissions to be requested:

NSArray *permissions = [NSArray arrayWithObjects:@"email", @"user_location", nil];

[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:
 ^(FBSession *session, FBSessionState state, NSError *error) {
     // some code here
 }];

Now when I try to read the users email from their /me data, it actually works for most users. Except for some, where I still do not get an email.

Am I missing something here? I thought when a user grants this request I always get an email address (even if it's an anonymized email). Or is there simply a facebook setting where users can turn this off entirely?

Upvotes: 0

Views: 2059

Answers (1)

anky_believeMe
anky_believeMe

Reputation: 484

I went through the Facebook documentation because I had this same hindrance:

note: this field will not be returned if no valid email address is available for the user

Source: https://developers.facebook.com/docs/reference/api/user/

Thus when an email address becomes invalid (users who haven't used facebook in years and have destroyed/changed their email address since for example), facebook may stop returning this field.

5% - 7% of invalid addresses may sound annoying, but when I check my facebook friends, I think more than 10% of them have stopped using their account, and so I decided its not a problem if I don't get their address.

Upvotes: 5

Related Questions