【发布时间】:2020-02-29 09:08:42
【问题描述】:
我以这种方式实现了来自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 委托中的 didCompleteMultifactorAuthenticationStepWithError 方法的回调。
对我的遗漏有什么想法吗?
【问题讨论】:
标签: ios swift amazon-cognito multi-factor-authentication