Fingerprint identification:

Starting with the iPhone5S, fingerprint recognition was introduced

Since iOS8.0, apple has allowed third-party apps to use Touch ID for authentication

Fingerprint identification Touch ID provides 3+2 = 5 fingerprint identification opportunities —–> After three identification failures, the fingerprint verification box will disappear (error code = -1 will be reported), then click the fingerprint will pop the box again to verify two times, if all five fingerprint identification errors, you need to manually enter the digital password, the digital password can be entered six times, If the password is entered incorrectly for six times, the system stops authentication. After the verification period, the system provides another authentication opportunity. If the password is entered correctly or successfully (once), the system accumulates the authentication time and waits for authentication, and so on.

IOS10 —–> 5 times after the problem: need to enter the setting — TouchID and password, input a password, you can unlock

Ideas:

1. Import the # import < > LocalAuthentication/LocalAuthentication. H

2. Check iOS8 and later versions

Create LocalAuthentication context object LAContext (LocalAuthentication)

4. Determine whether using fingerprint identification: the Evaluate: Evaluate the Policy: strategy LAPolicyDeviceOwnerAuthenticationWithBiometrics: equipment owner authorized use of biometrics

5. Successful call < some cases, need to do the cumulative number of errors, at this time need to exclude the user cancel >

Main code and comments:

//1. Check iOS8 and later versions

If ([UIDevice currentDevice]. SystemVersion. DoubleValue > = 8.0) {

// since iPhone5S, there is fingerprint recognition technology, so we can further determine whether it is a later model

//2. Create a LocalAuthentication context object –> import framework LocalAuthentication here

LAContext *context = [LAContext new];

// 3. Check whether fingerprint identification can be used

/ / the Evaluate: evaluation

/ / Policy: strategy

/ / LAPolicyDeviceOwnerAuthenticationWithBiometrics: equipment owner authorized use of biometrics

if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]){

//4. It will be called if it can be used

//localizedReason The local cause alert is displayed

[the context evaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason: @ “allow device fingerprinting” reply: ^ (BOOL success, NSError * _Nullable error) {

if (success) {

// Remember to update the UI in the main thread

dispatch_sync(dispatch_get_main_queue(), ^{

UIAlertController * ac = [UIAlertController alertControllerWithTitle: @ “prompt message:” @ “to identify successful” preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction * confirm = [UIAlertAction actionWithTitle: @ “sure” style: UIAlertActionStyleCancel handler: ^ (UIAlertAction *_Nonnull action){

}];

[ac addAction:confirm];

[self presentViewController:ac animated:true completion:^{

}];

ac = nil;

});

}

// No need to count user cancels

if(error.code ! = 2) {

// Fingerprint identification Touch ID provides 3+2 = 5 fingerprint identification opportunities —–> After 3 identification failures, the fingerprint verification box will disappear (error code = -1 will be reported), and then click the fingerprint will pop the box again to verify two times, if all five fingerprint identification errors, you need to manually enter the digital password, digital password can be entered 6 times, If the password is entered incorrectly for 6 times, the system stops the authentication. After the verification time, the system will provide the opportunity to verify again. If the password is correct and the verification is successful (1 time), the system will add the time to wait for the verification, and so on. Need to enter the Settings — TouchID and password, enter the password once, can unlock)

//Code=-2 “Canceled by user

//Code=-1 “Application retry limit exceeded.”

//Code=-8 “Biometry is locked out.”

NSLog(@”error: %@”, error);

}

}];

}else{

NSLog(@” Please make sure (5S +),TouchID is not turned on “);

}

}

Finally < code ideas, if there are similarities, not on purpose > attached to the demo address: demo