Add fingerprint recognition and fingerprint recognition in the Application
After iOS8, Apple released the fingerprint recognition function, which uses touch ID to identify users and perform user authorization, mainly relying on the LocalAuthentication library.
Fingerprint Recognition: 1. Determine whether a device supports fingerprint recognition.
2. Identify the fingerprint, and then perform the corresponding action. If the fingerprint fails, the user is reminded that the fingerprint recognition fails.
First introduce # import <LocalAuthentication/LocalAuthentication. h>
LAContext * context = [[LAContext alloc] init]; NSError * error = nil; // verify whether fingerprint recognition is supported if ([context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error: & error]) {NSLog (@ "Application Supporting fingerprint recognition"); // authentication identity [context evaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason: NSLocalizedString (@ "fingerprint is required to verify your identity ", @ "hello") reply: ^ (BOOL success, NSError * error) {if (success) {NSLog (@ "success");} else {switch (error. code) {case LAErrorUserCancel: NSLog (@ "the user has canceled authorization-% @", error. localizedDescription); break; case LAErrorUserFallback: NSLog (@ "the user clicked" Enter Password "button-% @", error. localizedDescription); break; case LAErrorAuthenticationFailed: NSLog (@ "you have failed authorization three times-% @", error. localizedDescription); break; case LAErrorTouchIDLockout: NSLog (@ "fingerprint locked-% @", error. localizedDescription); break; case LAErrorSystemCancel: NSLog (@ "the application enters the background-% @", error. localizedDescription); break; default: NSLog (@ "++ % @ -- % zd", error. localizedDescription, error. code); break ;}}] ;}else {switch (error. code) {case LAErrorPasscodeNotSet: NSLog (@ "no password set-% @", error. localizedDescription); break; case LAErrorTouchIDNotEnrolled: NSLog (@ "Touch ID not registered-% @", error. localizedDescription); break; case kLAErrorTouchIDNotAvailable: NSLog (@ "this device does not support Touch ID-% @", error. localizedDescription); break; default: NSLog (@ "-- % @ -- % zd", error. localizedDescription, error. code); break ;}}