IOS Touch ID uses

Source: Internet
Author: User

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 phone fingerprint with home key"; //determine if the phone has fingerprints    if([Context Canevaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics error:&ERROR]) {[Context evaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics Localizedreason:tip reply:^ (BOOL success, Nserror *error) {            if(Success) {//Validation SuccessfulNSLog (@"Success"); } Else{NSLog (@"%@", error.description); Switch(error.code) { CaseLaerrorsystemcancel:nslog (@"System Cancellation Authorization");  Break;  CaseLaerrorusercancel:nslog (@"User canceled");  Break;  CaseLaerroruserfallback:nslog (@"user Input Password");  Break; default:                         Break;    }            }        }]; } Else{NSLog (@"fingerprint recognition not supported,%@", error.description); }}

3.Laerror Enumeration related explanations

typedef ns_enum (Nsinteger, laerror) {///authentication was unsuccessful because the user did not provide valid credentialslaerrorauthenticationfailed =klaerrorauthenticationfailed,///canceled by the user (for example: "Cancel" button). Laerrorusercancel =Klaerrorusercancel,///the authentication was canceled because the user clicked the Fallback button (enter the password). Laerroruserfallback =Klaerroruserfallback,///validation is canceled through the system (for example, another application's application). Laerrorsystemcancel =Klaerrorsystemcancel,///authentication failed to start because the password was not set on the device. Laerrorpasscodenotset =Klaerrorpasscodenotset,///validation cannot be initiated because the Touch ID is not provided on the device. Laerrortouchidnotavailable =klaerrortouchidnotavailable,///validation cannot be started because the touch identity does not have a finger registered. laerrortouchidnotenrolled =klaerrortouchidnotenrolled,} Ns_enum_available (10_10, 8_0);

4.

If you do not see this article in the wb145230 Blog Park, please click here to view the original.

IOS Touch ID uses

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.