ios - 获取用户属性 AWS Amplify iOS SDK

标签 ios swift amazon-web-services amazon-cognito aws-amplify

我正在使用 SDK Amplify 构建一个 iOS 应用程序,以便让我的用户在 AWS 上注册。

我的登录/注册流程已经可以正常工作,但问题是,使用最新版本的 SDK,我完全不知道如何获取注册用户的属性,例如他的姓氏、电子邮件地址等。 ..

使用这个新的 SDK,一切似乎都围绕 AWSMobileClient 类进行,但我从该类中看不到任何可以帮助我获得所需内容的内容。

official documentation内容贫乏,没有涵盖甚至没有指出我的用例。

如果有人能给我一些提示,甚至一些好的资源,我将非常感激!

最佳答案

嗨 YoanGJ 和 future 的客人,

根据您的评论,您正在寻找一些示例代码。

    AWSMobileClient.sharedInstance().getUserAttributes { (attributes, error) in
            if let attributes = attributes {
                XCTAssertTrue(attributes.count == 3, "Expected 3 attributes for user.")
                XCTAssertTrue(attributes["email_verified"] == "false", "Email should not be verified.")
            }else if let error = error {
                XCTFail("Received un-expected error: \(error.localizedDescription)")
            }
            getAttrExpectation.fulfill()
}

此摘录显示了如何调用 getUserAttributes,它来自发现的集成测试 here .

关于ios - 获取用户属性 AWS Amplify iOS SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53657227/

相关文章:

ios - 在继承的类中覆盖 NSLayoutConstraint

ios - Swift:有没有一种简单的方法来绘制形状并检测它们是否相交?

ios - 无法在 iOS 中使用 slider 显示乘法表

ios - 如何使用swrevealviewcontroller打开菜单启动应用程序?

ios - CollectionView referenceSizeForHeaderInSection 是应用程序崩溃的原因

php - Laravel 数据库连接超时但可以通过 mysql 命令连接

iOS 导航栏出现褪色

ios - 在 UIImage 和 UIImageViews 中释放 Swift 中的内存

amazon-web-services - Cloudformation 堆栈长时间处于 UPDATE_COMPLETE_CLEANUP_IN_PROGRESS 状态

amazon-web-services - Kops Create Cluster 在 AWS Linux 中因八卦而失败