I'm opening the facebook session with the email permission like so:
- (void)facebookOpenSession {
NSArray *permissions = @[@"email"];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
And then the important snippet of session state changed looks like:
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error {
switch (state) {
case FBSessionStateOpen: {
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (error) {
//error
} else {
self.myFirstNameLabel.text = user.first_name;
self.myLastNameLabel.text = user.last_name;
// self.myEmailLabel.text = @"";
}
}];
}
...
How do I actually extract the user's email? Is it in one of the provided variables, or do I have to make another call within the completion handler?
Thanks in advance!
The current version of the Facebook SDK for iOS is version 14.1. 0. Code and samples for the Facebook SDK for iOS are available on GitHub. When you use the Facebook SDK for iOS, follow the Facebook Open Source Terms of Use and Privacy Policy.
The Facebook SDK enables: Facebook Login - Authenticate people with their Facebook credentials. Share and Send dialogs - Enable sharing content from your app to Facebook. App Events - Log events in your application.
What does this mean? By splitting up the Facebook Android SDK, you'll be able to integrate only the features you need. This makes Android apps simpler to develop and reduces app size. Today, the whole SDK is 335K.
FBGraphUser doesn't have the property (i'm assuming because its optional/only available if you asked for the email permission) but you should still be able to access it from the dictionary like this:
[user objectForKey:@"email"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With