0

我在我的应用程序中使用本地身份验证,但是当我在设置应用程序中更改设备的时间和日期并返回我的应用程序并按下此按钮时,我在我的应用程序中观察到了这种奇怪的行为,这LAContext()给了我一个错误

行为不端的调用者 PID:10565 发出了过多的身份验证请求。

错误代码为-4,是系统取消错误。我不知道为什么我会收到这个错误。

@IBAction func touchIdAction(_ sender: UIButton) {

        print("hello there!.. You have clicked the touch ID")

        let myContext = LAContext()
        let myLocalizedReasonString = "Biometric Authntication testing !! "

        var authError: NSError?
        if #available(iOS 8.0, macOS 10.12.1, *) {
            if myContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
                myContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: myLocalizedReasonString) { success, evaluateError in

                    DispatchQueue.main.async {
                        if success {
                            // User authenticated successfully, take appropriate action
                            self.successLabel.text = "Awesome!!... User authenticated successfully"
                        } else {
                            // User did not authenticate successfully, look at error and take appropriate action
                            self.successLabel.text = "Sorry!!... User did not authenticate successfully"
                        }
                    }
                }
            } else {
                // Could not evaluate policy; look at authError and present an appropriate message to user
                successLabel.text = "Sorry!!.. Could not evaluate policy."
            }
        } else {
            // Fallback on earlier versions

            successLabel.text = "Ooops!!.. This feature is not supported."
        }
    }
4

0 回答 0