ios - 可以只使用 TouchID 吗?
问题描述
我正在向我的应用程序添加生物识别,但我只想使用 Touch ID,我想使用 Face IS。
可能吗?或者使用 canEvaluatePolicy 我必须同时使用强制?
我正在使用这段代码,但我看不到这样做的一种方法。
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()
})
})
解决方案
我有同样的问题,但是当您实现代码以使用生物识别进行身份验证时。它是 Touch ID 或 Face ID,因此您无需担心要使用哪一个。因此,您的代码应该适用于触控 ID,例如 iPhone 6,适用于带有面容 ID 的 iPhone X。我希望这回答了你的问题。
推荐阅读
- regex - fn:matches 给出无效的正则表达式错误
- django - 如何在 django 中迁移特定表
- linux-kernel - gdb 不会在断点处停止 startup_32
- javascript - 通过用户输入通过函数更改全局变量
- c++ - 在上面把我推开?
- scala - Scala宏:限制变量名
- php - 如何在 Yajrabox 中添加显示数据按钮
- tensorflow - 在 Doc2Vec 模型中添加数据 ID
- android - 如何从android中的Amazon cognito用户池中检索用户名
- python - 从 Selenium 和 Python 中的灯箱下载有关 firefox 的 PDF