Ниже мой код. Когда я запускаю этот код и проверяю приложение с помощью TouchID, диалоговое окно аутентификации TouchID закрывается, и снова вызывается viewDidLoad (), который, в свою очередь, снова показывает предупреждение TouchID. Поэтому я не могу покинуть эту страницу и застрял в oop. Любая помощь будет оценена. Примечание: тот же код работал нормально 2 дня go.
override func viewDidLoad() {
super.viewDidLoad()
initialSetup()
checkAuthenticationMethod()
}
private func checkAuthenticationMethod() {
let biometricsEnabled = UserDefaults.standard.bool(forKey: LocalDefaults.biometricsEnabled.rawValue)
if biometricsEnabled {
OperationQueue.main.addOperation {
self.setupLocalAuthentication()
}
}
}
private func setupLocalAuthentication() {
var error: NSError?
context.localizedCancelTitle = "Login using your PIN"
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
if let err = error {
self.showAlert(message: err.localizedDescription, withTitle: "Error", willViewPop: false)
}else {
self.localAuthenticationMessage.isHidden = false
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Unlock App") { (success, error) in
DispatchQueue.main.async { [weak self] in
self?.view.isUserInteractionEnabled = !success
if success {
self?.showHUDLoader(containerView: nil,message: "Logging in", enableInteraction: false)
self?.pinImage.image = UIImage(named: "PIN_4")
self?.updateUserLoginToken()
}else if let err = error {
self?.pinImage.image = UIImage(named: "PIN_0")
let errorCode = (err as NSError).code
if errorCode != -4 {
self?.localAuthenticationMessage.isHidden = true
}
}
}
}
}
}
}