ios - 使用 AWS SDK iOS 版本 2.6.1 登录后无法访问用户详细信息 userName 和 imageURL

标签 ios swift amazon-web-services

我在使用 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?

对于谷歌:

https://developers.google.com/identity/sign-in/ios/people

关于ios - 使用 AWS SDK iOS 版本 2.6.1 登录后无法访问用户详细信息 userName 和 imageURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47548201/

相关文章:

ios - 将 YouTube 集成到我的 iOS 应用程序中

ios - 当非 void 方法在 Objective-C 中结束时会发生什么?

iOS Xcode 连接到 MySQL 数据库

ios - 如何以编程方式更改 UIButton 标签

amazon-web-services - 数据库迁移任务无法将数据加载到源数据库中

ios - Aspect 在自定义圆形 UIButton 中填充图像(图像将由用户更新)

ios - Swift:单击后退按钮后错过标签栏

ios - 类似枚举的功能的替代品并且能够在 Swift 中扩展

node.js - 如何将 API Gateway 授权方上下文传递给 HTTP 集成

java - Amazon ec2 上的 Jhipster 应用程序内存消耗