IOS fingerprint unlock verification TouchID, iostouchid

Source: Internet
Author: User

IOS fingerprint unlock verification TouchID, iostouchid
IOS fingerprint unlocking

1. First, introduce the dependency framework LocalAuthentication. framework

#import <LocalAuthentication/LocalAuthentication.h>

2. Then, determine whether the system is iOS8 or above.

// Only after iOS8.0 is supported can the fingerprint recognition interface if ([UIDevice currentDevice]. systemVersion. floatValue <8.0) {return ;}

3. At last, you can call the following method when the APP is started to integrate all features of fingerprint unlocking.

-(Void) evaluateAuthenticate {// create LAContext * context = [[LAContext alloc] init]; NSError * error = nil; NSString * result = @ "verify the existing fingerprint "; // first, use canEvaluatePolicy to determine the status of the device. if ([context canEvaluatePolicy: condition error: & error]) {// supports fingerprint verification. [context evaluatePolicy: Condition localizedReason: result reply: ^ (BOOL success, NSError * error) {if (success) {// Verification Successful, main thread processing UI} else {NSLog (@ "% @", error. localizedDescription); switch (error. code) {case LAErrorSystemCancel: {// The system cancels the authorization. For example, if other apps switch to break;} case LAErrorUserCancel: {// The user cancels the verification Touch ID break;} case LAErrorAuthenticationFailed: {// break failed to be authorized;} case LAErrorPasscodeNotSet: {// The password break is not set in the system;} case LAErrorTouchIDNotAvailable: {// The device Touch ID is unavailable, for example, break is not enabled ;} case LAErrorTouchIDNotEnrolled: {// The device Touch ID is unavailable and break is not input;} case LAErrorUserFallback: {[[NSOperationQueue mainQueue] addOperationWithBlock: ^ {// The user selects the input password, switch master thread processing}]; break;} default: {[[NSOperationQueue mainQueue] addOperationWithBlock: ^ {// in other cases, Switch master thread processing}]; break ;}}}] ;}else {// fingerprint identification is not supported, and NSLog (@ "fingerprint identification not supported") is used to output error details; switch (error. code) {case LAErrorTouchIDNotEnrolled: {NSLog (@ "TouchID is not enrolled"); break;} case LAErrorPasscodeNotSet: {NSLog (@ "A passcode has not been set "); break;} default: {NSLog (@ "TouchID not available"); break;} NSLog (@ "% @", error. localizedDescription );}}

 

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.