IOS fingerprint / face recognition, TouchID/FaceID verification

Are you still browsing a lot of documents to develop TouchID/FaceID recognition?
Use YZAuthID Only one callback method is needed to easily realize the verification and identification function of fingerprint / face ID. this project supports Pods for project construction, and you can go to Download the source code and run it to see the effect.
I won't elaborate on the authentication principle here. Let's take a look at the example renderings:

Prepare for certification
Start certification
Authentication failed

usage method

1. Introduction
  • Use CocoaPods method: pod 'YZAuthID'
  • Manual import method: drag all files under YZAuthID folder into the project, and import "YZAuthID.h" header file where needed
2. Coding

All the functions can be realized by calling YZ ﹐ showauthidwithdescription: blockstate: one method. The simple implementation code is as follows:

[[YZAuthID alloc] yz_showAuthIDWithDescribe:nil BlockState:^(YZAuthIDState state, NSError *error) {
        if (state == YZAuthIDStateNotSupport) {
            NSLog(@"Sorry, fingerprint is not supported on the current device/face ID");
        } else if(state == YZAuthIDStateFail) {
            NSLog(@"fingerprint/face ID Incorrect, authentication failed");
        } else if(state == YZAuthIDStateTouchIDLockout) {
            NSLog(@"Multiple errors, fingerprint/face ID It has been locked. Please enter the password in the unlocking interface of the mobile phone");
        } else if (state == YZAuthIDStateSuccess) {
            NSLog(@"Authentication succeeded!");

It returns the description of each state value of YZAuthIDState, which can be judged and processed according to the demand:

// The current device does not support TouchID/FaceID

// TouchID/FaceID verified successfully

// TouchID/FaceID validation failed

// TouchID/FaceID manually cancelled by user

// Users do not use TouchID/FaceID and choose to enter password manually

// TouchID/FaceID is cancelled by the system (e.g. in case of a call, screen lock, press Home key, etc.)
// TouchID/FaceID failed to start because the user did not set a password

// TouchID/FaceID failed to start because the user did not set the TouchID

// Invalid TouchID/FaceID

// TouchID/FaceID is locked (failed to verify TouchID/FaceID several times in a row, the system requires the user to enter the password manually)

// The current software is suspended and the authorization is cancelled (for example, App enters the background, etc.)

// Current software is suspended and unauthorized (LAContext object is invalid)

// TouchID/FaceID is not supported in the system version (must be higher than iOS 8.0 to use)

How about the whole authentication process? Is it Easy? If you have any questions or better suggestions, please leave a message!

Tags: github Mobile iOS

Posted on Mon, 04 May 2020 08:31:56 -0400 by mmarif4u