Android Fingerprint Auth

Improve this doc

$ ionic plugin add cordova-plugin-android-fingerprint-auth

Repo: https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth

This plugin will open a native dialog fragment prompting the user to authenticate using their fingerprint. If the device has a secure lockscreen (pattern, PIN, or password), the user may opt to authenticate using that method as a backup.

Usage

import { AndroidFingerprintAuth } from 'ionic-native';

AndroidFingerprintAuth.isAvailable()
  .then((result)=> {
    if(result.isAvailable){
      // it is available

      AndroidFingerprintAuth.encrypt({ clientId: "myAppName", username: "myUsername", password: "myPassword" })
        .then(result => {
           if (result.withFingerprint) {
               console.log("Successfully encrypted credentials.");
               console.log("Encrypted credentials: " + result.token);
           } else if (result.withBackup) {
             console.log('Successfully authenticated with backup password!');
           } else console.log('Didn\'t authenticate!');
        })
        .catch(error => {
           if (error === "Cancelled") {
             console.log("Fingerprint authentication cancelled");
           } else console.error(error)
        });

    } else {
      // fingerprint auth isn't available
    }
  })
  .catch(error => console.error(error));

Static Members

encrypt(options)

Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.

Param Type Details
options AndroidFingerprintAuthOptions

Options

Returns: Promise<any>

decrypt(options)

Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.

Param Type Details
options AndroidFingerprintAuthOptions

Options

Returns: Promise<any>

isAvailable()

Check if service is available

Returns: Promise<any> Returns a Promise that resolves if fingerprint auth is available on the device

delete()

Delete the cipher used for encryption and decryption by username

Returns: Promise<any> Returns a Promise that resolves if the cipher was successfully deleted

AndroidFingerprintAuthOptions

Param Type Details
clientId string

Required Used as the alias for your key in the Android Key Store.

username
(optional)
string

Used to create credential string for encrypted token and as alias to retrieve the cipher.

password
(optional)
string

Used to create credential string for encrypted token

token
(optional)
string

Required for decrypt() Encrypted user credentials to decrypt upon successful authentication.

disableBackup
(optional)
boolean

Set to true to remove the "USE BACKUP" button

locale
(optional)
string

Change the language. (en_US or es)

maxAttempts
(optional)
number

The device max is 5 attempts. Set this parameter if you want to allow fewer than 5 attempts.

userAuthRequired
(optional)
boolean

Require the user to authenticate with a fingerprint to authorize every use of the key. New fingerprint enrollment will invalidate key and require backup authenticate to re-enable the fingerprint authentication dialog.

dialogTitle
(optional)
string

Set the title of the fingerprint authentication dialog.

dialogMessage
(optional)
string

Set the message of the fingerprint authentication dialog.

dialogHint
(optional)
string

Set the hint displayed by the fingerprint icon on the fingerprint authentication dialog.

API

Native

General