Example code for fingerprint recognition in IOS applications _ios

Source: Internet
Author: User

After IOS8, Apple released the fingerprint recognition function, uses the Touch ID to identify the user, makes the user authorization, mainly relies on the Localauthentication library

Fingerprint identification: One to determine whether the device supports fingerprint recognition function

Two fingerprint identification, after the success of the corresponding action, failure to remind the user fingerprint recognition failed

First introduce#import <LocalAuthentication/LocalAuthentication.h>

Lacontext *context = [[Lacontext alloc] init];
  Nserror *error = nil; Verify that fingerprint recognition is supported if ([Context Canevaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics Error:&error]) {NSL
    OG (@ "Support fingerprint identification application"); Authentication [Context Evaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics localizedreason:nslocalizedstring (
      @ "Need fingerprints to verify your identity", @ "Hello") reply:^ (BOOL success, Nserror *error) {if (success) {NSLog (@ "successful"); else {switch (error.code) {case Laerrorusercancel:nslog (@ "User cancelled authorization-%@", error.localize
            Ddescription);
          Break
            Case Laerroruserfallback:nslog (@ "user clicks on" Enter Password "button-%@", error.localizeddescription);
          Break
            Case Laerrorauthenticationfailed:nslog (@ "You have been authorized to fail 3 times-%@", error.localizeddescription);
          Break
            Case Laerrortouchidlockout:nslog (@ "Fingerprint is locked-%@", error.localizeddescription);
          Break Case LaerrorSystemcancel:nslog (@ "app goes backstage-%@", error.localizeddescription);
          Break
            Default:nslog (@ "++%@--%zd", Error.localizeddescription, Error.code);
        Break
  }
      }
    }]; else {switch (error.code) {case Laerrorpasscodenotset:nslog (@ "Not set password-%@", Error.localizeddescripti
        ON);
      Break
        Case Laerrortouchidnotenrolled:nslog (@ "not registered touch ID-%@", 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.