我正在尝试通过以下方式获取用户的电子邮件地址:
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对象中,不会发送用户的电子邮件。任何想法如何解决这个问题?
谢谢
最佳答案
您必须在parameters
中提供您想要获得的内容:
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "email"]).startWithCompletionHandler({ (connection, result, error) -> Void in
例如,获得多个字段:
parameters: ["fields": "id, name, email, picture.type(large)"]
关于ios - iOS Facebook SDK 4.0.1获取用户的电子邮件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29590272/