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

Keychain Touch Id

Improve this doc

A cordova plugin adding the iOS TouchID / Android fingerprint to your app and allowing you to store a password securely in the device keychain.

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

Installation

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

Supported platforms

Usage

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


constructor(private keychainTouchId: KeychainTouchId) { }

...


this.keychainTouchId.isAvailable()
  .then((res: any) => console.log(res))
  .catch((error: any) => console.error(error));

Instance Members

isAvailable()

Check if Touch ID / Fingerprint is supported by the device

Returns: Promise<any> Returns a promise that resolves when there is hardware support

save(key, password)

Encrypts and Saves a password under the key in the device keychain, which can be retrieved after successful authentication using fingerprint

Param Type Details
key string

the key you want to store

password string

the password you want to encrypt and store

Returns: Promise<any> Returns a promise that resolves when there is a result

verify(key, message)

Opens the fingerprint dialog, for the given key, showing an additional message. Promise will resolve with the password stored in keychain or will resolve an error code, where -1 indicated not available.

Param Type Details
key string

the key you want to retrieve from keychain

message string

a message to the user

Returns: Promise<any> Returns a promise that resolves when the key value is successfully retrieved or an error

has(key)

Checks if there is a password stored within the keychain for the given key.

Param Type Details
key string

the key you want to check from keychain

Returns: Promise<any> Returns a promise that resolves with success if the key is available or failure if key is not.

delete(key)

Deletes the password stored under given key from the keychain.

Param Type Details
key string

the key you want to delete from keychain

Returns: Promise<any> Returns a promise that resolves with success if the key is deleted or failure if key is not

setLocale(locale)

Sets the language of the fingerprint dialog

Param Type Details
locale string

locale subtag from this list.

API

Native

General