0

I'm using local authentication in my app but I've observed this strange behavior in my app when I change the device's time and date in the settings app and return to my app and press this button, the LAContext() gives me an error

Misbehaving caller PID:10565 has made too many authentication requests.

The error code is -4 and it is a system cancel error. I don't know why I get this error.

@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."
        }
    }
Kamran
  • 14,987
  • 4
  • 33
  • 51
Omair Ahmed
  • 119
  • 1
  • 10
  • “when I change the device's time and date in the settings app” Why would you do that? – matt Sep 18 '19 at 06:05
  • Its a use case for quality assurance testing. – Omair Ahmed Sep 18 '19 at 06:07
  • Well clearly it confuses the system. – matt Sep 18 '19 at 06:08
  • 1
    Well, now you can be assured that the system will reject attempts to manipulate time :). I am not surprised that the system detects issues when time goes backward - particularly functions related to security & cryptography. You probably need to restart the device after changing the time backwards. – Paulw11 Sep 18 '19 at 06:09
  • Yeah, it's a likely possibility. – Omair Ahmed Sep 30 '19 at 07:16

0 Answers0