IOS Touch ID and iostouchid

Source: Internet
Author: User

IOS Touch ID and iostouchid

1. First import the header file

#import <LocalAuthentication/LocalAuthentication.h>

2. Key code

-(Void) validateTouchID {LAContext * context = [[LAContext alloc] init]; NSError * error; NSString * tip = @ "verify existing mobile phone fingerprints by using the Home Key "; // determine whether the mobile phone has a fingerprint if ([context canEvaluatePolicy: fingerprint error: & error]) {[context evaluatePolicy: Disable localizedReason: tip reply: ^ (BOOL success, NSError * error) {if (success) {// NSLog (@ "success");} else {NSLog (@ "% @", error. description); switch (error. code) {case LAErrorSystemCancel: NSLog (@ ""); break; case LAErrorUserCancel: NSLog (@ ""); break; case LAErrorUserFallback: NSLog (@ "user input password"); break; default: break ;}}];} else {NSLog (@ "fingerprint recognition is not supported, % @", error. description );}}

3. LAError Enumeration

Typedef NS_ENUM (NSInteger, LAError) {// authentication failed, because the user did not provide valid credenlalaerrorauthenticationfailed = kLAErrorAuthenticationFailed, // The user canceled the authentication (for example: "cancel" button ). LAErrorUserCancel = kLAErrorUserCancel, // The authentication is canceled because the user clicks the back button (enter the password ). LAErrorUserFallback = kLAErrorUserFallback, // The verification is canceled by the system (such as the application of another application. LAErrorSystemCancel = kLAErrorSystemCancel, // authentication fails because the password is not set on the device. LAErrorPasscodeNotSet = kLAErrorPasscodeNotSet, // verification cannot be started because the Touch ID is not provided on the device. LAErrorTouchIDNotAvailable = kLAErrorTouchIDNotAvailable, // verification cannot be started because the Touch ID has no registered finger. LAErrorTouchIDNotEnrolled = kLAErrorTouchIDNotEnrolled,} NS_ENUM_AVAILABLE (10_10, 8_0 );

4.

 

If you did not see this article in wb145230, click to view the original article.

 

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.