【问题标题】:How to retrieve email and phone_number from AWS Mobile Hub in Swift?如何在 Swift 中从 AWS Mobile Hub 检索电子邮件和电话号码?
【发布时间】:2018-06-09 03:55:55
【问题描述】:

有谁知道如何在 Swift 中从 AWS Mobile Hub 检索电子邮件和电话号码(如下图所示)?

我只知道如何使用以下代码检索用户名:

  let serviceConfiguration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:nil)
  let configuration = AWSCognitoIdentityUserPoolConfiguration(clientId: "clientId", clientSecret: "clientSecret", poolId: "poodId")
  AWSCognitoIdentityUserPool.register(with: serviceConfiguration, userPoolConfiguration: configuration, forKey: "Users")
  let pool = AWSCognitoIdentityUserPool(forKey: "Users")
  print(pool.currentUser()?.username)

任何建议将不胜感激。

【问题讨论】:

    标签: ios swift aws-cognito aws-mobilehub


    【解决方案1】:

    这是正确的方法:

    @objc func retrieveFromAttributes() {
    
            let dynamoDbObjectMapper = AWSDynamoDBObjectMapper.default()
            let newProfileAttributes: ProfileAttributes = ProfileAttributes()
            newProfileAttributes._userId = AWSIdentityManager.default().identityId
            dynamoDbObjectMapper.load(ProfileAttributes.self, hashKey: newProfileAttributes._userId, rangeKey: "Vincent Sun", completionHandler: { (objectModel: AWSDynamoDBObjectModel?, error: Error?) -> Void in
                if let error = error {
                    print("Amazon DynamoDB Read Error: \(error)")
                    return
                }
                    print("An item was read.")
    
                    DispatchQueue.main.async {
                    self.nameTextField.text = objectModel?.dictionaryValue["_nickname"] as? String
                }
    
    
            })
    
    
        }
    

    【讨论】:

      猜你喜欢
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 2018-03-16
      • 2018-05-05
      • 1970-01-01
      相关资源
      最近更新 更多