IOS Facebook SDK: login doesn't return email despite permissions granted
Facebook Graph API broke it’s backward compatibility (when used in a default fashion) Since Graph-API version 2.4 (Pod Version 4.4.0).
FB Graph-API 2.4 does NOT return all default fields for user
To resolve this you can either use explicitly graph version 2.3:
[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil tokenString:[FBSDKAccessToken currentAccessToken].tokenString version:@"v2.3" HTTPMethod:nil]
in which case FB assures v2.3 will be available at least 2 years from now.
https://developers.facebook.com/docs/graph-api/overview:
The Graph API has multiple versions available to access at any one
time. Each version contains a set ofcore fields and edge operations.
We make a guarantee that those core APIs will be available and
un-modified in that version for at least 2 years from release. The
platform changelog can tell you which versions are currently
available.
OR
you can use new Graph-API (v2.4) in by asking for specific fields you are interested in:
[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields" : @"email,name"}]
iOS FBSDKGraphRequest won't return e-mail
Turns out it was working, my e-mail address wasn't verified (although Facebook website said it was) so I had to add another e-mail account, verify it and then reset the original e-mail back to primary.
It worked after that.
iOS Facebook SDK: FBSDKGraphRequest not getting email, despite permission
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!
[Facebook-iOS-SDK 4.0]How to get user email address from FBSDKProfile
To fetch email you need to utilize the graph API, specifically providing the parameters field populated with the fields you want. Take a look at Facebook's Graph API explore tool, which can help to figure out the queries. https://developers.facebook.com/tools/explorer
The code that worked for me to fetch email is the following, which assumes you are already logged in:
NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
[parameters setValue:@"id,name,email" forKey:@"fields"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result, NSError *error) {
aHandler(result, error);
}];
Facebook Email field return null (even if the “email” permission is set and accepted)
I had the same problem and I think I found out why:
If the user has an unconfirmed email in Facebook (i.e. Facebook sent him a validation mail to the user's email address but he didn't respond) Facebook WILL NOT pass that email to your app even if he gave you the email permissions.
So what I did is use his or her Facebook email if the user has a user name (i.e. userName@facebook.com).
Related Topics
Does Swift Have a Null Coalescing Operator and If Not, What Is an Example of a Custom Operator
What Determines Whether a Swift 5.5 Task Initializer Runs on the Main Thread
Swift 3: Convert a Null-Terminated Unsafepointer<Uint8> to a String
Nstimer Does Not Invoke a Private Func as Selector
Swift Error: 'Missing Return in Function'
Ambiguous Use of Subscript (Swift 3)
Types Conforming to Multiple Protocols in Swift
Can't Create a Range in Swift 3
How to Capture Notifications in a Wkwebview
Checking If an Array of Custom Objects Contain a Specific Custom Object
Swift Map(_:) Extension for Set()
Constant Speed Orbit Around Point with Sknode
Creating a Countableclosedrange<Character>
Transform a Swift Sequence in to Adjacent Pairs
Swift Parsing Attribute Name for Given Elementname
How to Make Keyboard Dismiss When I Press Out of Searchbar on Swift
Extend Existing Protocols to Implement Another Protocol with Default Implements