我在許多地方描述了LocalAuthentication的以下實現。TouchID activateTouchWithResponse在不請求指紋的情況下返回成功
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Logging in with Touch ID", reply: { (success : Bool, error : NSError?) -> Void in
dispatch_async(dispatch_get_main_queue(), {
if success {
let alert = UIAlertController(title: "Success", message: "", cancelButtonTitle: "Great!")
self.presentViewController(alert, animated: true, completion: nil)
}
if let error = error {
var message :String
switch(error.code) {
case LAError..AuthenticationFailed:
message = "There was a problem verifying your identity."
case LAError..UserCancel:
message = "You pressed cancel."
case LAError..UserFallback:
message = "You pressed password."
default:
message = "Touch ID may not be configured"
}
let alert = UIAlertController(title: "Error", message: message, cancelButtonTitle: "Darn!")
self.presentViewController(alert, animated: true, completion: nil)
}
})
})
但之後我已經成功地與我的指紋驗證,然後evaluatePolicy(,localizedReason :,答覆:)返回成功,而不要求任何指紋。 我實際上使用UISwitch啓用或禁用TouchID,因此在禁用並重新啓用後,我想重新進行身份驗證並重新輸入指紋。
爲什麼它緩存身份驗證?
謝謝
添加錯誤,如果看到會發生什麼。 – Konsy
錯誤爲零。我第二次評估該政策時,我得到的成功和錯誤爲零,沒有被提示觸摸按鈕。 –
嘗試做,如果錯誤!=零而不是 – Konsy