作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
如许多地方所述,我有以下 LocalAuthentication 实现。
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:, reply:) 返回成功而不请求任何指纹。我实际上是在使用 UISwitch 启用或禁用 TouchID,因此在禁用并重新启用之后,我想重新验证并重新输入我的指纹。
为什么要缓存身份验证?
谢谢
最佳答案
LAContext 一旦被评估,将返回成功,直到它被释放。您可以手动使其无效,然后返回的错误将是 LAError.InvalidContext。
如果你想每次都提示 TouchID 确认,你需要每次都创建一个 LAContext。这可以实现
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)
}
context = LAContext()
})
})
关于ios - TouchID activateTouchWithResponse 返回成功而不请求指纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38379125/
如许多地方所述,我有以下 LocalAuthentication 实现。 context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBi
我是一名优秀的程序员,十分优秀!