Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Touch ID

Improve this doc

Scan the fingerprint of a user with the TouchID sensor.

Requires Cordova plugin: cordova-plugin-touch-id. For more info, please see the TouchID plugin docs.

Repo: https://github.com/EddyVerbruggen/cordova-plugin-touch-id

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-touch-id
    $ npm install --save @ionic-native/touch-id@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { TouchID } from '@ionic-native/touch-id';

constructor(private touchId: TouchID) { }

...

this.touchId.isAvailable()
  .then(
    res => console.log('TouchID is available!'),
    err => console.error('TouchID is not available', err)
  );

this.touchId.verifyFingerprint('Scan your fingerprint please')
  .then(
    res => console.log('Ok', res),
    err => console.error('Error', err)
  );

Error Codes

The plugin will reject for various reasons. Your app will most likely need to respond to the cases differently.

Here is a list of some of the error codes:

Instance Members

isAvailable()

Checks Whether TouchID is available or not.

Returns: Promise<any> Returns a Promise that resolves if yes, rejects if no.

verifyFingerprint(message)

Show TouchID dialog and wait for a fingerprint scan. If user taps ‘Enter Password’ button, brings up standard system passcode screen.

Param Type Details
message string

The message to display

Returns: Promise<any> Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above).

verifyFingerprintWithCustomPasswordFallback(message)

Show TouchID dialog and wait for a fingerprint scan. If user taps ‘Enter Password’ button, rejects with code ‘-3’ (see above).

Param Type Details
message string

The message to display

Returns: Promise<any> Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above).

verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message, enterPasswordLabel)

Show TouchID dialog with custom ‘Enter Password’ message and wait for a fingerprint scan. If user taps ‘Enter Password’ button, rejects with code ‘-3’ (see above).

Param Type Details
message string

The message to display

enterPasswordLabel string

Custom text for the 'Enter Password' button

Returns: Promise<any> Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above).

didFingerprintDatabaseChange()

Checks if the fingerprint database changed.

Returns: Promise<any> Returns a Promise that resolves if yes, rejects if no.

API

Native

General