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 https://github.com/micyo202/YZAuthID 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
YZAuthIDStateNotSupport

// TouchID/FaceID verified successfully
YZAuthIDStateSuccess

// TouchID/FaceID validation failed
YZAuthIDStateFail

// TouchID/FaceID manually cancelled by user
YZAuthIDStateUserCancel

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

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

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

// Invalid TouchID/FaceID
YZAuthIDStateTouchIDNotAvailable

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

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

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

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

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