Skip to main content

Authenticating

LocalAuthentication.authenticate(options?) shows the system prompt and resolves with an AuthenticationResult when it closes. It never rejects.

const result = await LocalAuthentication.authenticate({
promptMessage: 'Confirm the transfer',
})

Device fallback​

By default the user can fall back to the device passcode, PIN, pattern or password:

  • iOS evaluates deviceOwnerAuthentication, which offers the passcode after failed biometric attempts, or right away when no biometrics are enrolled.
  • Android allows DEVICE_CREDENTIAL in the same prompt (Android 10 and later), or uses the keyguard's confirm-credential screen (see Android versions).

Biometrics only​

Set disableDeviceFallback to accept only biometrics:

const result = await LocalAuthentication.authenticate({
promptMessage: 'Unlock the vault',
cancelLabel: 'Not now',
disableDeviceFallback: true,
biometricsSecurityLevel: 'strong',
})
EffectiOSAndroid
PolicydeviceOwnerAuthenticationWithBiometricsBiometric authenticators only, no DEVICE_CREDENTIAL
Cancel buttoncancelLabel, as alwaysShown as the negative button, cancelLabel or "Cancel"
Fallback buttonHidden unless you pass fallbackLabel; tapping it gives user_fallbackNone
Nothing enrollednot_enrollednot_enrolled
Android 8 and 9n/anot_available

Prompt text​

OptioniOSAndroid
promptMessageThe reason under the title. Defaults to "Authenticate".The title. Defaults to the app name.
promptSubtitleIgnored.The subtitle.
promptDescriptionIgnored.The description.
cancelLabelThe cancel button.The cancel button, only with disableDeviceFallback.
fallbackLabelThe fallback button after a failed attempt. '' hides it.Ignored.

Android biometric class​

biometricsSecurityLevel picks the class Android accepts. weak, the default, allows Class 2 biometrics such as most face unlock implementations; strong allows only Class 3. iOS biometrics are always strong, so iOS ignores it. Android 10 cannot enforce the class.

requireConfirmation (Android, default true) asks the user to tap after a passive match such as face unlock. Set it to false to finish as soon as the face matches.

One prompt at a time​

Only one prompt runs at a time. Calling authenticate while a prompt is open closes the earlier one, whose promise resolves with app_cancel, and opens the new one.

To close the prompt from code, for example on a timeout or navigation:

const pending = LocalAuthentication.authenticate({ promptMessage: 'Unlock' })
setTimeout(() => LocalAuthentication.cancelAuthenticate(), 30_000)
const result = await pending // { success: false, error: 'app_cancel' } after 30 s

cancelAuthenticate does nothing when no prompt is open.

:::info The keyguard screen cannot be closed

On Android 8 and 9, and on Android 10 without enrolled biometrics, the fallback is the keyguard's confirm-credential screen. cancelAuthenticate cannot close it: the promise resolves with app_cancel at once, the screen stays until the user leaves it, and its result is ignored.

:::