Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication failed and Try Face Id Again does nothing

I'm just follow this tutorial to authenticate user by Face ID but actually it's not work with "Try Face Id Again" button after authentication failed, the callback was not called and I don't know why. Here is the code:

@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."
    }


}

Running with Xcode 9.4.1 on iPhone X Simulator. Thanks

like image 746
maphongba008 Avatar asked Sep 10 '18 11:09

maphongba008


People also ask

How come my Face ID isn't working?

Your iPhone Face ID may not be working for several reasons, including: Your iPhone model doesn't support Face ID (the technology only works with iPhone X and later models). You need an iOS® update. Something is blocking the camera or your face.

Why won't my iPhone reset my Face ID?

Restart Your iPhone The first thing to do when iPhone Face ID is not working is restart your iPhone. This has the potential to fix a small software glitch that could be causing the problem. Press and hold the side button and either volume button until “slide to power off” appears on the screen.

Why Does My Face ID keep disabling?

The device hasn't been unlocked for more than 48 hours. The passcode hasn't been used to unlock the device in the last six and a half days and Face ID hasn't unlocked the device in the last 4 hours. The device has received a remote lock command. After five unsuccessful attempts to match a face.

Why is my Face ID not working after screen replacement?

Also, according to the feedback from our client, Face ID on the phone is available after being dropped. However, Face ID is not available after replacing of the display assembly. Unavailable Face ID might be caused by improper operation when replacing the display assembly.


1 Answers

Before tapping Try Face Id Again button you have to inform the simulator if it should simulate matching or non-matching face.

You can do it by selecting Hardware->Face ID->Matching Face/Non-matching Face

enter image description here

like image 124
loup4 Avatar answered Oct 02 '22 08:10

loup4