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 方法的回调。
对我的遗漏有什么想法吗?