📜  cordova-plugin-fingerprint-aio - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:00:02.157000             🧑  作者: Mango

cordova-plugin-fingerprint-aio

Cordova-plugin-fingerprint-aio is a fingerprint authentication plugin for Cordova/PhoneGap that supports Android and iOS devices. This plugin provides a simple and easy-to-use API for developers to enable fingerprint authentication in their apps.

Features
  • Supports Android and iOS devices
  • Provides a single API for fingerprint authentication
  • Supports both fingerprint (touch ID) and face (face ID) recognition
  • Fallback to password authentication if fingerprint authentication fails
  • Compatible with Cordova 6.0.0 or higher
Installation

To install the plugin in your Cordova project, run the following command:

cordova plugin add cordova-plugin-fingerprint-aio --save
Usage

To use this plugin in your app, you can call Fingerprint.show(options, successCallback, errorCallback) method, which shows a fingerprint authentication dialog.

Fingerprint.show({
    clientId: "myAppName",
    clientSecret: "myAppSecret",
    disableBackup:true,
    localizedReason: "Authenticate securely by scanning your fingerprint"
}, function(success){
    console.log("Auth succeeded");
}, function(error){
    console.log(error);
});
Options

The following options are available for Fingerprint.show() method:

| Option | Type | Description | | ------------------- | --------- | ------------------------------------------------------------------- | | clientId | String | The client ID to use for authentication. | | clientSecret | String | The client secret to use for authentication. | | localizedReason | String | The localized message displayed in the fingerprint dialog. | | disableBackup | Boolean | A flag indicating whether to disable the backup authentication. | | cancelText | String | The text to display on the cancel button. Default value: Cancel. | | fallbackButtonTitle| String | The text to display on the fallback button. Default value: Use Pin. | | disableAndroidCancel | Boolean | A flag indicating whether to disable the Android native dialog with cancel button. | | androidFingerPrintNotRecognizedTitle | String | The text to display on the fingerprint not recognized dialog title. Default value: Fingerprint not recognized. | | androidFingerPrintNotRecognizedMessage | String | The text to display on the fingerprint not recognized dialog message. Default value: Try again. | | androidNotAvailableTitle | String | The text to display on the fingerprint not available dialog title. Default value: Fingerprint not available. | | androidNotAvailableMessage | String | The text to display on the fingerprint not available dialog message. Default value: Try again. |

Success Callback

The successCallback function is called when the authentication is successful.

function(success){
    console.log("Auth succeeded");
}
Error Callback

The errorCallback function is called when the authentication fails.

function(error){
    console.log(error);
}
Notes
  • Fingerprint authentication only works on devices that support fingerprint recognition.
  • Make sure to handle the error case, since not all devices have fingerprint sensors.
  • The client ID and client secret are used to authenticate the app with the native fingerprint API.
  • If disableBackup is set to false, the user will be given the option to enter their backup password.
  • The plugin automatically handles the case where no fingerprints have been registered, presenting the fallbackButtonTitle button instead.
  • For iOS, make sure the NSFaceIDUsageDescription key is set in the app's Info.plist file.
License

This plugin is released under the MIT License.