Add fingerprint recognition and fingerprint recognition in the Application

Source: Internet
Author: User

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 ;}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.