我在使用 AWS SDK iOS 登录后尝试访问用户名和用户图像 url,但出现以下错误:
Value of type 'AWSIdentityManager' has no member 'identityProfile' Although the same code was working fine in previous SDK(2.5.10), please help me in getting the user details after login.
我当前的SDK版本是2.6.1
这是我的代码:-
if let identityUserName = identityManager.identityProfile?.userName {
print("User ID\( identityManager.identityId!)")
print("User name\(identityUserName)")
}
if let imageURL = identityManager.identityProfile?.imageURL {
print(imageURL)
}
如果我使用自定义登录名登录,我已设法使用以下代码访问用户名,但如果我尝试使用 Facebook 或 Gmail 登录,我得到的响应为零。
代码:-
let currUserPool = AWSCognitoIdentityUserPool.default()
let currUser = currUserPool.currentUser()
let username = currUser?.username
最佳答案
从 AWS Mobile Hub 下载的示例应用程序具有 IdentityProfile,可帮助您检索用户名和图像 URL。 08 月 31 日,IdentityProfile 已从示例应用程序中删除,AWSIdentityManager 已移至可用的 SDK 库
pod 'AWSAuthCore', '~> 2.6'
如果您使用的是 cocoapods。
对于用户池:
要从 UserPoolsSignIn 检索用户名,您可以执行以下操作:
添加这个导入:
import AWSUserPoolsSignIn
AWSCognitoUserPoolsSignInProvider.sharedInstance().getUserPool().currentUser()?.username
对于 Facebook:
How to get user name and email id for Facebook SDK?
对于谷歌:
关于ios - 使用 AWS SDK iOS 版本 2.6.1 登录后无法访问用户详细信息 userName 和 imageURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47548201/