所以我在使用生物识别技术对用户进行身份验证方面遵循书籍。下面是我在一个名为生物识别管理器的自定义类中编写的一些代码。
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
}
}
}
}
我已经调试了我的应用程序,它似乎导致评估策略行崩溃,我启用了异常断点来尝试捕获崩溃,但我在控制台日志中根本没有收到任何消息。我似乎在控制台中得到的唯一内容如下。
Message from debugger: Terminated due to signal 9
任何可能导致此崩溃发生的可能的指针或想法都没有太大帮助?
您需要将
NSFaceIDUsageDescription
密钥添加到info.plist
从 https://developer.apple.com/documentation/localauthentication/lacontext
重要
如果您的应用允许生物识别身份验证,请在应用的
Info.plist
文件中包括NSFaceIDUsageDescription
键。否则,授权请求可能会失败。