简体   繁体   中英

Make Face ID biometric authentication limit to 3

My app can use biometric authentication, and the ios app only tries the face id biometric for 2 times, the problem is, I need to make it try for 3 times before adding an option of entering it's password, how can I do that?

This is my code for accessing the biometric authentication

func loginWithBiometrics() {
        let context = LAContext()
        var error: NSError?

        if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
            let reason = "Identify yourself!"

            context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { [weak self] success, authenticationError in
                DispatchQueue.main.async {
                    if success {
                        print("success")
                    } else {
                        print("Failed biometric!")
                    }
                }
            }
        } else {
            print("Biometric not available!")
        }
}

It only tries the face id for 2 times and then suggest it to enter your password after 2 face id mistakes.

My expectation is to make the user try the face id for 3 times instead of 2.

According to Apple, Touch ID will attempt to verify three times, but Face ID will only attempt to verify the user twice. I can only assume this is because touch id tends to fail often under some circumstances like warm countries where sweat impedes with the sensor's ability to verify the fingerprint.

Policy evaluation fails if Touch ID or Face ID is unavailable or not enrolled. Evaluation also fails after three failed Touch ID attempts. After two failed Face ID attempts, the system offers a fallback option, but stops trying to authenticate with Face ID.

Resource: https://developer.apple.com/documentation/localauthentication/lapolicy/deviceownerauthenticationwithbiometrics

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM