在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)")
}https://stackoverflow.com/questions/47640118
复制相似问题