How to unauthenticate passwords when Touch ID crashes on iOS 8?

I am trying to implement Touch ID validation in my application and I want to fall back to password if it doesn't work (or is not available).

Here is my code:

 LAContext *ctx = [[LAContext alloc] init];
 [ctx evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Authenticate to access." reply:^(BOOL success, NSError *error) {
        if(success){
            [...]
        }else if(error.code != LAErrorUserFallback){
            [...] //error handler
        }
    }];

      

When I log in with Touch ID, success is called. When I can't auth after 3 touches, the error handler is called. No problem here. But when I press Enter Password, it should display the password entry screen, but nothing happens. How to display the password input screen?

+3


source to share


3 answers


You must first check if the TouchID is available by calling the LAContext[canEvaluatePolicy:error:]

method , which will return NO

if the TouchID isn Available.



And LAErrorUserFallback for YOUR application is the own password (authentication) of the schema, not the device. More information can be found here on this subject .

+2


source


you have to use LAPolicyDeviceOwnerAuthentication instead of LAPolicyDeviceOwnerAuthenticationWithBiometrics for LAContext`s Method

evaluatePolicy: localizedReason: kReasonTitle: response

and



canEvaluatePolicy: Error:

LAPolicyDeviceOwnerAuthentication:

If Touch ID is available, registered and not locked, it is first asked for it, otherwise they will be prompted for a device password which will display the password entry screen .

+1


source


Use LAPolicyDeviceOwnerAuthentication

instead LAPolicyDeviceOwnerAuthenticationWithBiometrics

.

It first asks for Touch ID if available and register it to the device. If you've used Touch ID incorrectly 3 times, the Enter Password button will appear. Clicking this button will open the device code screen.

+1


source







All Articles