0

所以我正在尝试使用他们的电话号码将用户登录到我的应用程序。为此,我从 Twitter 的 Fabric Kit 以及 AWS Cognito 中集成了 Digit。我能够使用数字对用户进行身份验证并成功获取会话对象,并且可以提取用户 ID、电话号码、authToken 和 authTokenSecret。但是我无法将经过数字身份验证的用户与 cognito 链接起来。本质上credentialsProvider.logins = ["www.digits.com": value](即使它执行)在配置的认知身份池中根本没有影响。

这是我的viewcontroller.swift

import UIKit
import DigitsKit

let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: AWSRegionType.USEast1, identityPoolId: "IDENTITY_POOL_ID")

let defaultServiceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)


class ViewController: UIViewController {

@IBAction func login(sender: AnyObject) {
    let digits = Digits.sharedInstance()
    digits.authenticateWithCompletion { (session, error) in
        if (session != nil) {
            println("session user id is: " + session.userID)
            println("session mobile no is: " + session.phoneNumber)
            println("session token is: " + session.authToken)
            println("session authtoken secret is: " + session.authToken)
            var value = session.authToken + ";" + session.authTokenSecret

            //THIS PART DOES NOT SET DIGIT LOGIN WITH COGNITO
            credentialsProvider.logins = ["www.digits.com": value]
        }
        // Inspect session/error objects
    }


}

@IBAction func logout(sender: AnyObject) {
        }
override func viewDidLoad() {
    super.viewDidLoad()

    AWSServiceManager.defaultServiceManager().
defaultServiceConfiguration = defaultServiceConfiguration

    // Do any additional setup after loading the view, typically from a nib.

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

我已经替换了正确的身份池 ID,并将消费者密钥和秘密复制到了 amazon cognito 池。我已禁用未经身份验证的 ID。我究竟做错了什么?

4

1 回答 1

1

AWSCognitoCredentialsProvider 被延迟加载。简单地设置登录字典不足以导致登录出现在控制台中。请尝试以下方法之一:

  1. 您可以使用凭证提供程序访问任何其他服务,例如使用 Amazon Cognito Sync 服务来存储身份信息并同步到云。
  2. 您还可以强制凭证提供商调用 Amazon Cognito Identity 服务。如果您没有缓存的身份 ID,该getIdentitId方法将调用服务来建立您的身份 ID。
  3. 如果您已经缓存了身份,则可以使用该refresh方法强制使用登录字典的内容进行重新身份验证。
于 2015-06-06T20:57:13.187 回答