Fingerprint

The fingerprint feature enables you to implement fingerprint authentication in your mobile application.

Supported Platforms

This feature is supported in the following platforms:

  • iOS
  • Android

Installation

iOS

This plugin requires the following:

  • iOS 8 version (minimum)
  • iPhone 5S or newer mobile device that has a fingerprint scanner

To install the Fingerprint plugin for iOS, execute the following command in your Cordova project directory:

cordova plugin add cordova-plugin-touch-id

Android

To install the Fingerprint plugin for Android, execute the following command in your Cordova project directory:

cordova plugin add cordova-plugin-android-fingerprint-auth

Usage

Assume that there are two buttons "AVAIL FINGERPRINT SCANNER" and "AUTHENTICATE" on your mobile applications that checks if the fingerprint scanner is configured and authenticates the fingerprint respectively. The following is a sample code snippet that can be used in the listener JS file for invoking the fingerprint scanner and authenticating the fingerprint.

/* The following function checks whether or not the user has configured the fingerprint scanner.
*  Here, CFEC.CLICK is the Canvas event that can be used to capture the button clicked action.
*  AVAIL is the form item ID for the "AVAIL FINGERPRINT SCANNER" button. 
*/ 
this.fm.registerHandler(CFEC.CLICK, "AVAIL", 
                      	function (fm, event, fieldName, value) 
						{
            				canvas.env.util.fingerPrint.isAvailable(SuccessCallback, ErrorCallback);
        				});

/* To authenticate the fingerprint, the following method opens a native dialog fragment 
*  to use the device hardware fingerprint scanner to authenticate against fingerprints 
*  registered for the device.
*  Here, CFEC.CLICK is the Canvas event that can be used to capture the button clicked action.
*  AVAIL is the form item ID for the "AVAIL FINGERPRINT SCANNER" button.
*/
this.fm.registerHandler(CFEC.CLICK, "AUTHENTICATE", 
                        function (fm, event, fieldName, value) 
						{
            				var params = 
							{
                				buttonLabel: "Enter your PIN", 
								popupMessage: "Please scan your fingerprint",
								clientSecret: "Used to encrypt the token returned upon successful fingerprint authentication.",
								clientId: "Used as the alias for your key in the Android Key Store"
            				};
            				canvas.env.util.fingerPrint.authenticate(params, successCallback, errorCallback);
        				});


/* SuccessCallback will get called only when the fingerprint or touch ID is available on a device.
*  If the SuccessCallback handler was called, you can scan the fingerprint.
*/
function SuccessCallback(result) 
{
    showAlert("available");
}

// ErrorCallback will get called if the device has no touch ID available.
function ErrorCallback(error) 
{
    showAlert("not available:" + error);
}