我正在使用电子邮件权限打开 facebook 会话,如下所示:
- (void)facebookOpenSession {
NSArray *permissions = @[@"email"];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
然后会话状态的重要片段更改如下所示:
- (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 = @"";
}
}];
}
...
我如何实际提取用户的电子邮件?它是在提供的变量之一中,还是我必须在完成处理程序中进行另一个调用?
提前致谢!