Ionic 4 Face ID and Fingerprint Plug-in (Biometric Authentication) App

Introduction

In this tutorial, we'll demonstrate how to integrate the Fingerprint and Face ID biometric authentication into your Appery.io mobile app.

Creating App

  1. From the Appery.io dashboard, create a new Ionic 4 app of Ionic 4 Blank type.
  2. Click Create new > From plugin; in the Security section, select FaceId and Fingerprint Login plug-in and click Import selected plugins:

You'll see that the FingerprintAuthentification page and two generic services have appeared in the project tree:

Also, you can check the App settings > Cordova plugins tab and see that the FingerprintAllInOne Cordova plug-in is enabled:

📘

Cordova Plug-in Fingerprint All-In-One

The plug-in sources, examples, and documentation can be found on this GitHub page.

  1. Go to Project > Routing and set BiometricAuthentification as a default route. Save the changes:

App Testing

Let's test the app. Export the .apk or .ipa file and install it on your device. The plug-in works on both Android 6+ and iOS.

📘

Face ID, supported devices

You can check the iPhone and iPad models that support Face ID here: https://support.apple.com/en-us/HT209183

When you click the Check availability button, the service will check if the Fingerprint or Face ID authentication method is supported by your device. The Biometric login button shows the authentication dialog.

Once the scanned fingerprint or face matches the one registered on your device, the success login status will be returned:

App work on Android, Fingerprint authenticationApp work on Android, Fingerprint authentication

App work on Android, Fingerprint authentication

App work on iOS, Fingerprint authenticationApp work on iOS, Fingerprint authentication

App work on iOS, Fingerprint authentication

Importing Service to Existing App Page

You may also need to import the BiometricLogin service to the existing app page, for example, Screen1.

  1. Let's go to the Screen1 page and click its DATA panel.
  2. Here, add BiometricLoginService as a datasource and rename it to biometricLogin:
  1. You can delete the Before send mapping because the service doesn't take any request parameters.
  2. All we need to do is to add some actions for the Success and Error events. We can show an alert in case of error, and navigate to another page (you can create a new page, Home, for example) in case of successful user authentication:
  1. To invoke the service, you need to expand the EVENTS tab and create a new event with Invoke service as the Action and biometricLogin as the Datasource. For example, we can invoke it on the button click:
  1. Finally, go to Project > Routing and set Screen1 as a default route.
    The app should work like this:
Successful authentication in an Android deviceSuccessful authentication in an Android device

Successful authentication in an Android device

If the fingerprint (or face) is not recognized, an error warning will be shown:

Authentication errorAuthentication error

Authentication error

📘

Want to know more?

You might also like this Appery.io Community video that shows how to create an Ionic 4 application with the functionality of social authentication via Facebook by adding the Facebook Login plug-in: