所以我正在阅读有关使用生物识别技术验证用户身份的书籍。下面是我在名为生物识别管理器的自定义类中编写的一些代码。
func authenticateUser(completion: @escaping (_ result: BiometricsStatus) -> Void) {
DispatchQueue.main.async {
guard self.deviceHasBiometricCapabilities() else { completion(.fail(error: .touchIDNotAvailable)); return }
let authMethod = self.biometricType() == .faceID ? "Face ID" : "Touch ID"
let loginMessage = "\(authMethod) to sign in"
self.context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: loginMessage) { success, evaluateError in
if success {
completion(.success)
return
}
if let error = evaluateError {
completion(.fail(error: self.getBiometricsError(from: error)))
return
}
}
}
}
我已经调试了我的应用程序,它似乎导致评估策略行崩溃,我启用了异常断点来 try catch 崩溃,但我在控制台日志中没有收到任何信息。我似乎在控制台中得到的唯一内容如下。
Message from debugger: Terminated due to signal 9
这对于可能导致此崩溃发生的任何可能的指针或想法都不是非常有帮助吗?
最佳答案
您需要将 NSFaceIDUsageDescription
键添加到 info.plist
来自https://developer.apple.com/documentation/localauthentication/lacontext
Important
Include the
NSFaceIDUsageDescription
key in your app’sInfo.plist
file if your app allows biometric authentication. Otherwise, authorization requests may fail.
关于ios - 使用生物识别技术对用户进行身份验证导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51771462/