0.1.1 • Published 5 years ago

capacitor-biometric-auth v0.1.1

Weekly downloads
30
License
MIT
Repository
github
Last release
5 years ago

Capacitor Biometric Auth

CI

Installation

  • npm i capacitor-biometric-auth
  • yarn add capacitor-biometric-auth

Setup

Don't for get to run npx cap sync before doing the next steps.

Android

To get android working please add this code to your MainActivity file.

MainActivity.java

++ import com.ahm.capacitor.biometric.BiometricAuth;

this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ ++ add(BiometricAuth.class); }});

### IOS

@TODO

## Usage

```ts
import { Plugins } from "@capacitor/core";

const { BiometricAuth } = Plugins;

const available = await BiometricAuth.isAvailable()

if (available.has) {
  const authResult = await BiometricAuth.verify({...})
  if (authResult.verified) {
    // success authentication
  } else {
    // fail authentication
  }
} else {
  // biometric not available
}

Methods

verify(options)

Open biometric popup

optionvaluesdecription
reasonany stringPopup label for iOS
titleany stringTitle of prompt in Android
subTitleany stringSubtitle of prompt in Android
descriptionany stringDescription of prompt in Android
cancelany stringText for cancel button on prompt in Android
const result = await BiometricAuth.verify({reason: "Message ..."})

result

{
  verified: true // true if biometric auth was succes or false otherwise,
  status: {} // an object with errors matching biometric auth fails (on if verified === false)
}

status

errordescription
10The user failed to provide valid credentials
11Authentication was cancelled by application
12The context is invalid
13Not interactive
14Passcode is not set on the device
15Authentication was cancelled by the system
16The user did cancel
17The user chose to use the fallback

isAvailable()

Checks if biometric is enabled

const result = await BiometricAuth.isAvailable()

result

{
  has: true, // true if has biometric auth enabled, false otherwise
  status: {...} // an object with errors
}

status

errordescription
1Biometric not available
2Authentication could not continue because the user has been locked out of biometric authentication, due to failing authentication too many times.
3Authentication could not start because the user has not enrolled in biometric authentication.
0.1.1

5 years ago

0.1.0

5 years ago

0.0.8

5 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

4.0.13

6 years ago

4.0.11

6 years ago

4.0.10

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago