使用AWS开发工具包iOS版本2.6.1登录后无法访问用户详细信息userName,imageURL [英] Unable to access user details userName , imageURL after login using AWS SDK iOS version 2.6.1
问题描述
我尝试使用AWS开发工具包iOS登录后访问用户名和用户图像URL,但出现以下错误:
I am trying to access the user name and user Image url after login using AWS SDK iOS but i am getting following error :
类型"AWSIdentityManager"的值没有成员"identityProfile"尽管相同的代码在以前的SDK(2.5.10)中可以正常工作,请登录后帮助我获取用户详细信息.
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
My current SDK version is 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登录,则无响应.
I have managed to access the user Name by using following code if i login with custom login , but if i try to login with Facebook or Gmail i get nil in response.
代码:-
let currUserPool = AWSCognitoIdentityUserPool.default()
let currUser = currUserPool.currentUser()
let username = currUser?.username
推荐答案
从AWS Mobile Hub下载的示例应用程序具有IdentityProfile,它可以帮助您检索用户名和imageURL.在08/31上,从示例应用程序中删除了IdentityProfile,并将AWSIdentityManager移到了一个SDK库中,该库可用于 pod'AWSAuthCore','〜>2.6'
(如果您正在使用cocoapods).
The Sample Application downloaded from AWS Mobile Hub had the IdentityProfile which helps you retrieve the username and imageURL. On 08/31, the IdentityProfile was removed from the Sample Application and the AWSIdentityManager was moved to an SDK library available as
pod 'AWSAuthCore', '~> 2.6'
if you are using cocoapods.
对于用户池:
要从UserPoolsSignIn中检索用户名,您可以执行以下操作:
For retrieving the username from UserPoolsSignIn, you can do the following:
添加此导入:
import AWSUserPoolsSignIn
AWSCognitoUserPoolsSignInProvider.sharedInstance().getUserPool().currentUser()?.username
对于Facebook:
For Facebook:
对于Google:
https://developers.google.com/identity/sign-in/ios/people
这篇关于使用AWS开发工具包iOS版本2.6.1登录后无法访问用户详细信息userName,imageURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!