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!
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: