如何使用移动中心用户签名功能获取用户详细信息?
How to get the user details using mobile hub User-sign feature?
我正在使用 AWS Mobile Hub 服务进行用户登录。我遵循移动中心开发人员指南,并且能够使用 Facebook 成功登录。登录后如何获取用户详细信息,如个人资料图片或姓名或出生日期等。移动中心的开发人员指南没有解释这一点。是否可以获取详细信息或仅对用户进行身份验证?
目前帮助您执行Facebook SignIn的AWS Auth SDK不支持获取用户个人资料信息可以直接使用Facebook iOS SDK获取用户名,图片URL等信息
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()
我正在使用 AWS Mobile Hub 服务进行用户登录。我遵循移动中心开发人员指南,并且能够使用 Facebook 成功登录。登录后如何获取用户详细信息,如个人资料图片或姓名或出生日期等。移动中心的开发人员指南没有解释这一点。是否可以获取详细信息或仅对用户进行身份验证?
目前帮助您执行Facebook SignIn的AWS Auth SDK不支持获取用户个人资料信息可以直接使用Facebook iOS SDK获取用户名,图片URL等信息
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()