我正在尝试使用以下内容获取用户的电子邮件地址:
fbLoginManager.logInWithReadPermissions(["email", "public_profile"], handler: { (loginResult, error) -> Void in
if error != nil {
//handle error
} else if loginResult.isCancelled {
//handle cancellation
} else {
//Logged in
self.loggedinUser.fbToken = FBSDKAccessToken.currentAccessToken().tokenString
var graphReq = FBSDKGraphRequest(graphPath: "me", parameters: nil).startWithCompletionHandler { (connection, result, error) -> Void in
if let user = result as? NSDictionary {
var email = result.objectForKey("email") as? String
var name = result.objectForKey("name") as? String
self.loggedinUser.email = email ?? nil
self.loggedinUser.fullName = name ?? nil
}
}
}
})
但是在 loginResult 对象中,用户的电子邮件没有被发送。知道如何解决这个问题吗?
谢谢
最佳答案
您必须在参数
中提供您想要得到的内容:
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "email"]).startWithCompletionHandler({ (connection, result, error) -> Void in
例如获取多个字段:
parameters: ["fields": "id, name, email, picture.type(large)"]
关于iOS Facebook SDK 4.0.1 获取用户的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29590272/