在iOS 11上,当应用程序使用主页按钮后退时,与打开外部webview链接并进入safari时,应用程序状态似乎有所不同。
在返回我的应用时,我要求用户使用触摸ID进行验证。如果应用程序使用主页按钮后退并返回,则对LAPolicy.deviceOwnerAuthenticationWithBiometrics
的调用会显示提示并等待用户交互。但是,用户通过应用程序中的链接转到外部网站,然后使用"返回应用程序返回应用程序"状态栏中显示的按钮,对LAPolicy.deviceOwnerAuthenticationWithBiometrics
的调用会立即导致错误而不显示触摸ID提示。
我已经检查过两次调用时的应用程序状态是应用程序是active
。它是在主线程上完成的,它是在applicationDidBecomeActive上完成的。
这是我看到的错误:
Error Domain=com.apple.LocalAuthentication Code=-1004 "User interaction is required." UserInfo={NSLocalizedDescription=User interaction is required.}`
对LAPolicy.deviceOwnerAuthenticationWithBiometrics
行为的任何见解?用于调用它的代码是:
let context = LAContext()
context.localizedFallbackTitle = ""
print("--> internalAuthenticateBiometrics background \(UIApplication.shared.applicationState == UIApplicationState.background)")
context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason:NSLocalizedString("Place your finger to sign in.",comment: "")) { [weak self] (success, error) in
print("--> internalAuthenticateBiometrics completion success \(success) error \(error)")
}
答案 0 :(得分:0)
我们发现此特定问题发生在旧版本的iOS 11上。我们正在具有iOS 11.0.3和11.1.2的设备上进行测试。我将操作系统更新为11.4,问题消失了。
截至目前,我只能假设Apple已修复一些应用程序前景和生物识别问题。仅供参考,这个问题与背景视图或被覆盖的视图没有任何关系,因为我们确保一切都可见,appDidEnterForeground被调用,viewDidAppear正在发生,并且甚至在几秒钟后添加了触发生物识别的延迟。