从Facebook获取用户电子邮件ID的代码。
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (error) {
//error
}else{
control.name.text=user.name;
self.myFirstNameLabel.text = user.first_name;
self.myLastNameLabel.text = user.last_name;
self.myEmailLabel.text = ???
NSLog(@"name :%@",user.name);
NSLog(@"email is :%@",[user objectForKey:@"email"]);
}
}];
获取电子邮件ID的权限:
{
NSArray *permissions = [NSArray arrayWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
但仍然显示null.please help
提前致谢。
答案 0 :(得分:0)
我有一段时间遇到过类似的问题。我为了解决方案而四处寻找。但最终它发现我使用的facebook测试帐户没有附加vaild电子邮件ID。我用来登录facebook的Gmail帐户已被删除!