在我的iOS 7 iPad应用程序中,LAContext:evaluatePolicy有时会返回成功,而不会提示用户触摸ID按钮。苹果公司的文档说:“评估一个策略可能涉及到提示用户…”。。
我的身份验证策略设置为LAPolicyDeviceOwnerAuthenticationWithBiometrics,是我看到的唯一选择。为什么不在我每次调用evaluatePolicy时提示用户触摸ID按钮呢?有没有一种方法可以要求这种行为?
发布于 2016-05-18 17:33:16
我也遇到过类似的问题。可以声明一个全局变量,如下所示
let authenticationContext = LAContext()然后在类方法和函数中使用authenticationContext。
我已经开始在我使用它的每个函数中声明常量,如下所示
func someAuthFunc() {
let authenticationContext = LAContext()
...我的问题就解决了。我每次请求evaluateForContext时都会被问到...
我希望这能帮到你。
干杯
发布于 2019-10-16 16:44:48
适用于有相同问题的人的
这只会发生在iOS 13和更高版本中。解决方案是尝试调用evaluate函数两次,如下所示:
let systemVersion = UIDevice.current.systemVersion
// Trick here: Try to do a pre-evaluate
if systemVersion.compare("13.0", options: .numeric) != .orderedAscending {
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to open the app", reply: { (_, _) in
//Ignore callback here
})
}
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to open the app", reply: { (success, error) in
// Handle callback here
})到目前为止,所有iOS 13.x.x版本都经过测试,工作正常。
发布于 2019-10-09 19:47:36
在iOS13更新后,我遇到了同样的问题。这不是一个很好的解决方法,但是调用evaluatePolicy两次为我解决了这个问题
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { _, _ in
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { isSuccess, _ in
DispatchQueue.main.async {
if isSuccess {
success()
} else {
fail(authError?.localizedDescription ?? "User did not authenticate successfully")
}
}
}
}https://stackoverflow.com/questions/35094167
复制相似问题