将面容 ID 生物识别身份验证限制设置为 3



我的应用程序可以使用生物识别身份验证,而ios应用程序只尝试面部ID生物识别2次,问题是,我需要让它尝试3次才能添加输入密码的选项,我该怎么做?

这是我访问生物识别身份验证的代码

func loginWithBiometrics() {
let context = LAContext()
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
let reason = "Identify yourself!"
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { [weak self] success, authenticationError in
DispatchQueue.main.async {
if success {
print("success")
} else {
print("Failed biometric!")
}
}
}
} else {
print("Biometric not available!")
}
}

它只尝试面部 ID 2 次,然后在 2 次面部 ID 错误后建议它输入您的密码。

我的期望是让用户尝试面部 ID 3 次而不是 2 次。

根据苹果的说法,Touch ID将尝试验证三次,但Face ID只会尝试验证用户两次。我只能假设这是因为触摸ID在某些情况下往往会失败,例如温暖的国家,汗水阻碍了传感器验证指纹的能力。

如果触控 ID 或面容 ID 不可用或未注册,策略评估将失败。三次触控 ID 尝试失败后,评估也会失败。两次面容 ID 尝试失败后,系统会提供回退选项,但会停止尝试使用面容 ID 进行身份验证。

资源:https://developer.apple.com/documentation/localauthentication/lapolicy/deviceownerauthenticationwithbiometrics

相关内容

最新更新