我正在使用AWS Mobile Hub服务进行用户登录。我关注移动中心开发者指南,我成功地使用Facebook登录。记录之后 - 如何获取用户详细信息,如个人资料图片或名称或DOB等。移动中心的开发人员指南不解释这一点。是否可以获取详细信息,还是仅用于验证用户身份?
答案 0 :(得分:0)
目前帮助您执行Facebook SignIn的AWS Auth SDK不支持检索用户个人资料信息,可直接使用Facebook iOS SDK获取包括用户名,imageURL等信息。
let imageGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "picture.type(large)"])
let imageConnection = FBSDKGraphRequestConnection()
imageConnection.add(imageGraphRequest, completionHandler: { (connection, result, error) in
guard let imageResult = result as? NSDictionary else { return}
if let imageURL = URL(string:(((imageResult.value(forKey: "picture") as AnyObject).value(forKey: "data") as AnyObject).value(forKey: "url") as? String)!) {
self.imageURL = imageURL
}
})
imageConnection.start()
let userGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, email"])
let userConnection = FBSDKGraphRequestConnection()
userConnection.add(userGraphRequest, completionHandler: { (connection, result, error) in
guard let userResult = result as? NSDictionary else { return }
if let userName = userResult.value(forKey: "name") as? String {
self.userName = userName
}
})
userConnection.start()