ios - iOS Local Biometric authentication dialogue called again and again
问题描述
Below is my code. When ever I run this code and validate the app using TouchID, TouchID Authentication dialog is dismissed and viewDidLoad() is called again which in turn shows the TouchID alert again. So I am not able to leave this page and stuck in a loop. Any help would be appreciated. Note: Same code was working fine 2 days ago.
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
}
}
}
}
}
}
}
解决方案
推荐阅读
- r - shinyWidgets 中未使用的参数错误:airDatepickerInput
- python-3.x - 使用 python 进行 Instagram 网页抓取
- python - 是否可以在函数中嵌入 argsparse 解析器?
- combobox - 组合框是否需要具有文本框角色的子元素?
- windows - 与 I/O 操作相关的 sys 包问题
- python - 在 pyinstaller 中找不到模块
- android-espresso - 如何在 Kotlin Flow 中使用 Espresso?
- lisp - 打印输入数字的总和
- python - Celery as a service - PermissionError: [Errno 13] Permission denied: '/var/run/celery'
- parsing - SYSLOG-NG:将相同的日志发送到弹性搜索中的两个不同索引