AWSCognitoIdentityMultiFactorAuthentication永不返回

我以这种方式实现了https://github.com/awslabs/aws-sdk-ios-samples/blob/master/CognitoYourUserPools-Sample/Swift/CognitoYourUserPoolsSample/MFAViewController.swift中的示例:

import Foundation
import UIKit
import AWSMobileclient
import AWSCognitoIdentityProvider

class MFAModalViewController: UIViewController {

    @IBOutlet weak var messageLabel: UILabel!
    @IBOutlet var backgroundView: UIView!
    @IBOutlet weak var boxView: UIView!
    @IBOutlet weak var mfaTextField: UITextField!

    public var message: String?
    var mfaCompletionSource: AWSTaskCompletionSource<NSString>?

    @IBaction func mfaTextFieldChanged(_ sender: Any) {
        if let mfaCode = mfaTextField.text,mfaCode.count == 6 {

            self.mfaCompletionSource?.set(result: NSString(string: mfaCode))
        }
    }

    override func viewDidLoad()
    {
        super.viewDidLoad()

        if let message = message {
            messageLabel.text = message
        }
    }
}

extension MFAModalViewController: AWSCognitoIdentityMultiFactorauthentication {
    func getcode(_ authenticationInput: AWSCognitoIdentityMultifactorauthenticationInput,mfaCodeCompletionSource: AWSTaskCompletionSource<NSString>) {
        hud.dismiss()

        self.mfaCompletionSource = mfaCodeCompletionSource
    }

    func didCompleteMultifactorauthenticationStepWithError(_ error: Error?) {
        ...
    }
}

但是,在将AWSTaskComplettionSource设置为输入的MFA代码之后,我再也没有收到 AWSCognitoIdentityMultiFactorauthentication 委托内的 didCompleteMultifactorauthenticationStepStepWithError 方法的回调。

对我的遗漏有什么想法吗?

hanyu294674597 回答:AWSCognitoIdentityMultiFactorAuthentication永不返回

好的,解决方案是不使用AWSCognitoIdentify,而使用AWSMobileClient。我错过了MFA验证方法:

AWSMobileClient.sharedInstance().confirmSignIn(challengeResponse: mfaCode) { (signInResult,error) in

    DispatchQueue.main.async {self.handleConfirmation(signInResult: signInResult,error: error)}
     }
}
本文链接:https://www.f2er.com/3169238.html

大家都在问