ios - 使用生物识别技术对用户进行身份验证导致应用程序崩溃

标签 ios swift biometrics touch-id face-id

所以我正在阅读有关使用生物识别技术验证用户身份的书籍。下面是我在名为生物识别管理器的自定义类中编写的一些代码。

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’s Info.plist file if your app allows biometric authentication. Otherwise, authorization requests may fail.

关于ios - 使用生物识别技术对用户进行身份验证导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51771462/

相关文章:

iOS 8 可达性在模拟器中总是返回 false

ios - 如何创建对角线切割 View 以在配置文件屏幕中使用?

java - 从生物识别指纹考勤设备中检索数据

ios - 在没有 Storyboard 的情况下继续查看

ios - 使用 Swift 从 UIImage 构建视频

ios - 3D touch quick actions preview view controller 只有一次

swift - 如何在 Swift 中为文件访问指定备用目录

javascript - 下载在 WKWebView 中加载的嵌入式 PDF

安卓指纹检测新增手指

java - 从 ISO/IEC 19794-4 图像数据文件创建图像