Mutawe
Mutawe

Reputation: 6524

Touch ID: Biometry is locked out. Code=-8

Im using Touch id to identify iPhone users in my app, when is use canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics to evaluate if the user is eligible for using Touch id, but after many failed tries even if the user is eligible for using touch id, it returns FALSE.

And that will lead the app to skip this step and thinks that the touch id is not supported in this device.

Here is the error i get:

Error Domain=com.apple.LocalAuthentication Code=-8 "Biometry is locked out." UserInfo={NSLocalizedDescription=Biometry is locked out.}

Upvotes: 8

Views: 8721

Answers (2)

Prasad Patil
Prasad Patil

Reputation: 127

You can unlock the biometry by authenticating the user using passcode. Just paste this function in your project and call this function before authenticating user using Touch ID.

If it returns true run Touch ID authentication and if it fails due to biometry lock out than it will ask user to enter iPhone passcode to unlock biometry. This will happen within the app.

func isBiometryReady() -> Bool
{
        let context : LAContext = LAContext();
                var error : NSError?

            context.localizedFallbackTitle = ""
            context.localizedCancelTitle = "Enter Using Passcode"

            if (context.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error))
            {
                    return true
            }

            if error?.code == -8
            {
                let reason:String = "TouchID has been locked out due to few fail attemp. Enter iPhone passcode to enable TouchID.";
                context.evaluatePolicy(LAPolicy.deviceOwnerAuthentication,
                                       localizedReason: reason,
                                       reply: { (success, error) in

                                        return false

                })

                return true


            }

    return false
}

Upvotes: 0

tgebarowski
tgebarowski

Reputation: 1379

Ok, I think that I found the answer. Hopefully it will help you. When you get

Error Domain=com.apple.LocalAuthentication Code=-8 "Biometry is locked out." UserInfo={NSLocalizedDescription=Biometry is locked out.}

iOS 10 blocks access to TouchID, it can be either unlocked by providing passcode on iOS unlock screen, accessing TouchID iOS settings and providing the passcode there or manually triggering the passcode screen from within the app. You can open the passcode screen using, following snippet.

let context = LAContext()
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthentication,
                           localizedReason: reason,
                           reply: { (success, error) in
})

Of course you can first check if this policy can be evaluated.

So in the end, when the user successfully enters passcode, the biometry will be unlocked. Before iOS 10, this was done automatically by the operating system.

Upvotes: 14

Related Questions