gpt4 book ai didi

ios - TouchID activateTouchWithResponse 返回成功而不请求指纹

转载 作者:IT王子 更新时间:2023-10-29 05:22:26 25 4
gpt4 key购买 nike

如许多地方所述,我有以下 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com