@capgo/capacitor-native-biometric

中文文档
8.9.1发布于 2026/10/21MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 97.2万

This plugin gives access to the native biometric apis for android and iOS

原始使用文档
文档目录32 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Native Biometric?
  4. Documentation
  5. ⚠️ Security Considerations
  6. Important: verifyIdentity() Can Be Bypassed on Rooted/Jailb…
  7. Recommended Security Practices
  8. Secure Usage Pattern
  9. What This Plugin Provides
  10. Recent Security Improvements (v8.2.0+)
  11. Compatibility
  12. Installation (Only supports Capacitor 7)
  13. Usage
  14. Complete Login Flow Example
  15. Biometric Auth Errors
  16. isAvailable(...)
  17. addListener('biometryChange', ...)
  18. verifyIdentity(...)
  19. getCredentials(...)
  20. setCredentials(...)
  21. deleteCredentials(...)
  22. getSecureCredentials(...)
  23. isCredentialsSaved(...)
  24. setData(...)
  25. getData(...)
  26. getSecureData(...)
  27. deleteData(...)
  28. isDataSaved(...)
  29. getPluginVersion()
  30. Interfaces
  31. Type Aliases
  32. Enums

Capacitor Native Biometric

Add Face ID, Touch ID and fingerprint login to your Capacitor app, and keep credentials safe in the iOS Keychain and Android Keystore.

Capgo - Instant updates for Capacitor

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

@capgo/capacitor-native-biometric for Capacitor apps

Key features

  • Biometric check: isAvailable() returns the biometry type, with optional device credential fallback.
  • Authenticate: verifyIdentity() shows the native biometric prompt.
  • Credentials: setCredentials(), getCredentials(), getSecureCredentials() and deleteCredentials() per server.
  • Secure data: setData(), getData() and getSecureData() store any string value.
  • Change events: the biometryChange listener runs when the app resumes, so you can detect enrollment changes made while it was in the background.
  • Platforms: iOS, Android and Web. Web provides mocks for development.

Why Native Biometric?

A free, comprehensive biometric authentication plugin with secure credential storage:

  • All biometric types - Face ID, Touch ID, Fingerprint, Face Authentication, Iris, and Device Credentials (PIN, pattern, password)
  • Secure credential storage - Keychain (iOS) and Keystore (Android) integration
  • Flexible fallback - Optional passcode fallback when biometrics unavailable
  • Customizable UI - Full control over prompts, titles, descriptions, button text
  • Detailed error codes - Unified error handling across iOS and Android
  • Resume listener - Detect biometry availability changes when app returns from background
  • Modern package management - Supports both Swift Package Manager (SPM) and CocoaPods (SPM-ready for Capacitor 8)

Perfect for banking apps, password managers, authentication flows, and any app requiring secure user verification.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/native-biometric/

⚠️ Security Considerations

Important: verifyIdentity() Can Be Bypassed on Rooted/Jailbroken Devices

The verifyIdentity() method should not be used as the sole authentication mechanism for sensitive operations. On rooted Android devices or jailbroken iOS devices, attackers can use tools like Frida, Xposed, or similar frameworks to:

  • Hook the JavaScript bridge and force verifyIdentity() to return success
  • Intercept native method calls and bypass biometric authentication
  • Modify the app's runtime behavior to skip authentication checks
  1. Use Root/Jailbreak Detection: Protect your app by detecting compromised devices. We recommend using the @capgo/capacitor-is-root plugin to detect rooted/jailbroken devices:
import { IsRoot } from '@capgo/capacitor-is-root';

async function checkDeviceSecurity() {
  const { result } = await IsRoot.isRooted();
  
  if (result) {
    // Handle rooted device - show warning, restrict features, or block access
    console.warn('Device security compromised');
    return false;
  }
  return true;
}
  1. Never Store Sensitive Data Client-Side: Don't rely on locally stored credentials for critical authentication. Use verifyIdentity() as a convenience feature, not a security boundary.

  2. Server-Side Verification: Always validate authentication on your backend server. Biometric authentication should be used for user convenience, with the real authentication happening server-side.

  3. Implement Additional Security Layers:

    • Use certificate pinning for API calls
    • Implement server-side session management
    • Use short-lived tokens that expire after biometric auth
    • Add anti-tampering checks

Secure Usage Pattern

import { NativeBiometric } from "@capgo/capacitor-native-biometric";
import { IsRoot } from '@capgo/capacitor-is-root';

async function secureAuthentication() {
  // 1. Check device security first
  const { result } = await IsRoot.isRooted();
  if (result) {
    // Handle rooted device appropriately
    // Example: showSecurityWarning() could display an alert to the user
    showSecurityWarning();
    // Optionally: disable biometric login, require re-authentication, etc.
  }

  // 2. Perform biometric authentication
  try {
    await NativeBiometric.verifyIdentity({
      reason: "Authenticate to access your account",
      title: "Biometric Login",
    });
  } catch (error) {
    console.error("Biometric authentication failed");
    return false;
  }

  // 3. Get stored credentials (if needed for convenience)
  const credentials = await NativeBiometric.getCredentials({
    server: "www.example.com",
  });

  // 4. CRITICAL: Validate credentials with your backend server
  // Example: validateWithServer() should send credentials to your API
  // and verify them server-side before granting access
  const isValid = await validateWithServer(credentials.username, credentials.password);
  
  return isValid;
}

What This Plugin Provides

This plugin provides:

  • ✅ Convenient local biometric authentication UI
  • ✅ Secure credential storage using Keychain (iOS) and Keystore (Android)
  • ✅ Protection against casual unauthorized access

This plugin does NOT provide:

  • ❌ Protection against determined attackers on compromised devices
  • ❌ Server-side authentication or validation
  • ❌ Root/jailbreak detection (use @capgo/capacitor-is-root)

Recent Security Improvements (v8.2.0+)

Android Encryption Enhancement: The Android implementation now uses properly randomized Initialization Vectors (IVs) for AES-GCM encryption of stored credentials. Previous versions used a fixed IV, which is a cryptographic vulnerability.

Automatic Migration: The plugin automatically handles credentials encrypted with the older method:

  • When reading credentials, it first attempts the new secure format, then falls back to the legacy format if needed
  • When saving credentials, they are always encrypted using the new secure format
  • No action required from users - migration happens transparently on first credential save after update

Recommendation: After updating to v8.2.0+, users should re-save their credentials to ensure they're encrypted with the improved format. This happens automatically when users authenticate and save credentials again.

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Installation (Only supports Capacitor 7)

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-native-biometric` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

  • npm i @capgo/capacitor-native-biometric

Usage

⚠️ Important: Before implementing biometric authentication, review the Security Considerations section to understand limitations and best practices for secure implementation.

import { NativeBiometric, BiometryType } from "@capgo/capacitor-native-biometric";

async performBiometricVerification(){
  const result = await NativeBiometric.isAvailable();

  if(!result.isAvailable) return;

  // Check the biometry type for display purposes
  // IMPORTANT: Always use isAvailable for logic decisions, not biometryType
  const isFaceID = result.biometryType == BiometryType.FACE_ID;

  // Check if device has PIN/pattern/password set
  console.log('Device is secure:', result.deviceIsSecure);

  // Check if strong biometry (Face ID, Touch ID, fingerprint) is available
  console.log('Strong biometry available:', result.strongBiometryIsAvailable);

  const verified = await NativeBiometric.verifyIdentity({
    reason: "For easy log in",
    title: "Log in",
    subtitle: "Maybe add subtitle here?",
    description: "Maybe a description too?",
  })
    .then(() => true)
    .catch(() => false);

  if(!verified) return;

  const credentials = await NativeBiometric.getCredentials({
    server: "www.example.com",
  });
  
  // IMPORTANT: Always validate credentials with your backend server
  // Do not trust client-side verification alone
}

// Save user's credentials
NativeBiometric.setCredentials({
  username: "username",
  password: "password",
  server: "www.example.com",
}).then();

// Check if credentials are already saved
const isSaved = await NativeBiometric.isCredentialsSaved({
  server: "www.example.com",
});
console.log('Credentials saved:', isSaved.isSaved);

// Delete user's credentials
NativeBiometric.deleteCredentials({
  server: "www.example.com",
}).then();

// Listen for biometry availability changes when app resumes from background
const handle = await NativeBiometric.addListener('biometryChange', (result) => {
  console.log('Biometry availability changed:', result.isAvailable);
  console.log('Biometry type:', result.biometryType);
});

// To remove the listener when no longer needed:
// await handle.remove();

Complete Login Flow Example

This example shows how to use isCredentialsSaved() to check if credentials are already saved before showing a "save credentials" popup:

// After successful login
async handleLoginSuccess(username: string, password: string) {
  // Check if biometric authentication is available
  const result = await NativeBiometric.isAvailable({ useFallback: true });
  
  if (!result.isAvailable) {
    // Biometrics not available - go to home page directly
    this.navigateToHome();
    return;
  }
  
  // Check if credentials are already saved
  const checkCredentials = await NativeBiometric.isCredentialsSaved({
    server: "www.example.com"
  });
  
  if (checkCredentials.isSaved) {
    // Credentials already saved - go to home page
    this.navigateToHome();
  } else {
    // No credentials saved - show save credentials popup
    this.showSaveCredentialsPopup(username, password);
  }
}

// Save credentials when user confirms
async saveCredentials(username: string, password: string) {
  await NativeBiometric.setCredentials({
    username: username,
    password: password,
    server: "www.example.com",
  });
  this.navigateToHome();
}

Biometric Auth Errors

This is a plugin specific list of error codes that can be thrown on verifyIdentity() failure, set as part of isAvailable(), or returned from getSecureCredentials() and getSecureData() when no biometric-protected item exists for the requested server or key. It consolidates Android and iOS specific authentication error codes into one combined error list.

CodeDescriptionPlatform
0Unknown ErrorAndroid, iOS
1Biometrics UnavailableAndroid, iOS
2User LockoutAndroid, iOS
3Biometrics Not EnrolledAndroid, iOS
4User Temporary LockoutAndroid (Lockout for 30sec)
10Authentication FailedAndroid, iOS
11App CanceliOS
12Invalid ContextiOS
13Not InteractiveiOS
14Passcode Not SetAndroid, iOS
15System CancelAndroid, iOS
16User CancelAndroid, iOS
17User FallbackAndroid, iOS
21No Protected Credentials/Data FoundAndroid, iOS

Code 21 (getSecureCredentials, getSecureData), Stable, expected rejection when no biometric-protected credentials or data exist (for example after deletion, a fresh install, or items invalidated by biometric enrollment changes). Platform messages differ slightly:

  • getSecureCredentials()
    • Android: No protected credentials found
    • iOS: No protected credentials found for server
  • getSecureData()
    • Android: No protected data found
    • iOS: No protected data found for key

isCredentialsSaved() and isDataSaved() return true when any credentials or data exist for the server or key (protected or unprotected), so they do not guarantee that getSecureCredentials() or getSecureData() will succeed. Handle code 21 in your catch block, or only call after storing with accessControl BIOMETRY_CURRENT_SET or BIOMETRY_ANY. See getSecureCredentials() and getSecureData() for details.

isAvailable(...)

isAvailable(options?: IsAvailableOptions | undefined) => Promise<AvailableResult>

Checks if biometric authentication hardware is available.

ParamType
optionsIsAvailableOptions

Returns: Promise<AvailableResult>

Since: 1.0.0


addListener('biometryChange', ...)

addListener(eventName: 'biometryChange', listener: BiometryChangeListener) => Promise<PluginListenerHandle>

Adds a listener that is called when the app resumes from background. This is useful to detect if biometry availability has changed while the app was in the background (e.g., user enrolled/unenrolled biometrics).

ParamTypeDescription
eventName'biometryChange'- Must be 'biometryChange'
listenerBiometryChangeListener- Callback function that receives the updated AvailableResult

Returns: Promise<PluginListenerHandle>

Since: 7.6.0


verifyIdentity(...)

verifyIdentity(options?: BiometricOptions | undefined) => Promise<void>

Prompts the user to authenticate with biometrics.

ParamType
optionsBiometricOptions

Since: 1.0.0


getCredentials(...)

getCredentials(options: GetCredentialOptions) => Promise<Credentials>

Gets the stored credentials for a given server.

ParamType
optionsGetCredentialOptions

Returns: Promise<Credentials>

Since: 1.0.0


setCredentials(...)

setCredentials(options: SetCredentialOptions) => Promise<void>

Stores the given credentials for a given server.

ParamType
optionsSetCredentialOptions

Since: 1.0.0


deleteCredentials(...)

deleteCredentials(options: DeleteCredentialOptions) => Promise<void>

Deletes the stored credentials for a given server.

ParamType
optionsDeleteCredentialOptions

Since: 1.0.0


getSecureCredentials(...)

getSecureCredentials(options: GetSecureCredentialsOptions) => Promise<Credentials>

Gets the stored credentials for a given server, requiring biometric authentication. Credentials must have been stored with accessControl set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY.

On iOS, the system automatically shows the biometric prompt when accessing the protected Keychain item. On Android, BiometricPrompt is shown with a CryptoObject bound to the credential decryption key.

If no protected credentials exist for the server, the promise rejects with code 21 (BiometricAuthError.NO_PROTECTED_CREDENTIALS_FOUND). This is stable, expected behavior — for example when credentials were never saved with biometric protection, were deleted, or were invalidated after biometric enrollment changes. isCredentialsSaved() returns true when any credentials (protected or unprotected) exist, so it does not guarantee a biometric-protected entry is present — handle code 21 in your catch block or only call after storing with accessControl BIOMETRY_CURRENT_SET or BIOMETRY_ANY. Platform messages: Android No protected credentials found, iOS No protected credentials found for server.

ParamType
optionsGetSecureCredentialsOptions

Returns: Promise<Credentials>

Since: 8.4.0


isCredentialsSaved(...)

isCredentialsSaved(options: IsCredentialsSavedOptions) => Promise<IsCredentialsSavedResult>

Checks if credentials are already saved for a given server.

ParamType
optionsIsCredentialsSavedOptions

Returns: Promise<IsCredentialsSavedResult>

Since: 7.3.0


setData(...)

setData(options: SetDataOptions) => Promise<void>

Stores an arbitrary string value under the given key. Values are encrypted at rest using the platform secure storage backend (Android Keystore + SharedPreferences, iOS Keychain).

For biometric-protected storage, set accessControl and retrieve the value with getSecureData(). Credential helpers remain available for username/password flows.

ParamType
optionsSetDataOptions

Since: 8.6.0


getData(...)

getData(options: GetDataOptions) => Promise<StoredData>

Gets a previously stored value for the given key. Only returns values stored without biometric accessControl.

ParamType
optionsGetDataOptions

Returns: Promise<StoredData>

Since: 8.6.0


getSecureData(...)

getSecureData(options: GetSecureDataOptions) => Promise<StoredData>

Gets a biometric-protected value for the given key. The value must have been stored with accessControl set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY.

ParamType
optionsGetSecureDataOptions

Returns: Promise<StoredData>

Since: 8.6.0


deleteData(...)

deleteData(options: DeleteDataOptions) => Promise<void>

Deletes the stored value for the given key (protected and unprotected).

ParamType
optionsDeleteDataOptions

Since: 8.6.0


isDataSaved(...)

isDataSaved(options: IsDataSavedOptions) => Promise<IsDataSavedResult>

Checks whether a value is already saved for the given key.

ParamType
optionsIsDataSavedOptions

Returns: Promise<IsDataSavedResult>

Since: 8.6.0


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version.

Returns: Promise<{ version: string; }>

Since: 1.0.0


Interfaces

AvailableResult

Result from isAvailable() method indicating biometric authentication availability.

PropTypeDescription
isAvailablebooleanWhether authentication is available. On Android, weak-only biometrics (such as some face unlock implementations) are available for verifyIdentity() when no allowedBiometryTypes filter excludes them. If useFallback is true, PIN/pattern/password can also make this value true.
authenticationStrengthAuthenticationStrengthThe strength of available authentication method (STRONG, WEAK, or NONE)
biometryTypeBiometryTypeThe primary biometry type available on the device. On Android devices with multiple biometry types, this returns MULTIPLE. Use this for display purposes only - always use isAvailable for logic decisions.
deviceIsSecurebooleanWhether the device has a secure lock screen (PIN, pattern, or password). This is independent of biometric enrollment.
strongBiometryIsAvailablebooleanWhether strong biometry (Face ID, Touch ID, or fingerprint on devices that consider it strong) is specifically available, separate from weak biometry or device credentials.
errorCodeBiometricAuthErrorError code from BiometricAuthError enum. Only present when isAvailable is false. Indicates why biometric authentication is not available.

IsAvailableOptions

PropTypeDescriptionDefaultSince
useFallbackbooleanWhether passcode or device credentials should count toward biometric availability when no biometric is enrolled or available. - On iOS, this affects both isAvailable() and verifyIdentity(). - On Android, this is honored by isAvailable() only — the native check computes fallbackAvailable = useFallback && deviceIsSecure and reports availability accordingly. The verifyIdentity() flow ignores this option on Android due to BiometricPrompt API constraints (DEVICE_CREDENTIAL authenticator and negative button are mutually exclusive); use BiometricOptions.useFallback (iOS-only) to control the auth-dialog fallback there.
preferMultipleBiometryTypebooleanAndroid only. Report BiometryType.MULTIPLE whenever a fingerprint is enrolled and the device also advertises a face or iris sensor, even when that second modality cannot be confirmed as enrolled. You normally do not need this. On Android 12 and newer a face enrolled next to a fingerprint is usually detected and reported as BiometryType.MULTIPLE on its own. Detection is best-effort, and is not possible on Android 11 and older, for the rare Class 3 (Strong) face sensor, or on a vendor build whose biometric labels name only the preferred modality. Undetected devices report BiometryType.FINGERPRINT, because most devices advertise a face sensor the user never enrolled. Set this to true if your UI would rather over-report MULTIPLE there. verifyIdentity() is unaffected and still offers every enrolled biometric the device supports; this only changes the reported type. The most recent value is reused for biometryChange events.false8.6.5

PluginListenerHandle

PropType
remove() => Promise<void>

BiometricOptions

PropTypeDescriptionDefault
reasonstring
titlestring
subtitlestring
descriptionstring
negativeButtonTextstring
useFallbackbooleanOnly for iOS. Specifies if should fallback to passcode authentication if biometric authentication fails. On Android, this parameter is ignored due to BiometricPrompt API constraints: DEVICE_CREDENTIAL authenticator and negative button (cancel) are mutually exclusive.
fallbackTitlestringOnly for iOS. Set the text for the fallback button in the authentication dialog. If this property is not specified, the default text is set by the system.
maxAttemptsnumberOnly for Android. Set a maximum number of attempts for biometric authentication. The maximum allowed by android is 5.1
allowedBiometryTypesBiometryType[]Only for Android. Specify which biometry types are allowed for authentication. If not specified, all enrolled biometric classes (strong and weak) are allowed. On Android, face unlock is often classified as weak biometrics — include BiometryType.FACE_AUTHENTICATION or omit this option to allow it. Use BiometryType.DEVICE_CREDENTIAL for PIN/pattern/password (disables the cancel button).

Credentials

PropType
usernamestring
passwordstring

GetCredentialOptions

PropType
serverstring

SetCredentialOptions

PropTypeDescriptionDefaultSince
usernamestring
passwordstring
serverstring
accessControlAccessControlAccess control level for the stored credentials. When set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY, the credentials are hardware-protected and require biometric authentication to access. On iOS, this adds SecAccessControl to the Keychain item. On Android, this creates a biometric-protected Keystore key and requires BiometricPrompt authentication for both storing and retrieving credentials.AccessControl.NONE8.4.0
authValidityDurationnumberOnly for Android. Ignored on iOS and web. Only meaningful together with accessControl set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY. Number of seconds a successful biometric authentication remains valid for Keystore key use. When 0 or omitted (the default), the Keystore key requires a fresh authentication for every operation — each getSecureCredentials() call shows a BiometricPrompt cryptographically bound to that specific read via a CryptoObject. This is the strongest mode: it guarantees no code path can use the key without a live biometric check. When set to a value greater than 0, one successful biometric authentication authorizes Keystore key use for that many seconds. Subsequent getSecureCredentials() calls within the window succeed without showing a prompt. This trades security for convenience: any in-app code that can reach the decryption call — not just the code path that triggered the prompt — can silently read the credentials for the remainder of the window.08.5.0
titlestringTitle for the biometric prompt shown while protecting credentials. Only for Android."Protect Credentials"8.4.14
negativeButtonTextstringText for the negative/cancel button in the biometric prompt. Only for Android."Cancel"8.4.14
maxAttemptsnumberSet a maximum number of attempts for biometric authentication. The maximum allowed by Android is 5. Only for Android.1

DeleteCredentialOptions

PropType
serverstring

GetSecureCredentialsOptions

PropTypeDescriptionDefault
serverstring
reasonstringExplanation text shown as the subtitle of the Touch ID prompt. Face ID does not display it. Only for iOS.
titlestringTitle for the biometric prompt. Only for Android.
subtitlestringSubtitle for the biometric prompt. Only for Android.
descriptionstringDescription for the biometric prompt. Only for Android.
negativeButtonTextstringText for the negative/cancel button. Only for Android.
maxAttemptsnumberSet a maximum number of attempts for biometric authentication. The maximum allowed by Android is 5. Only for Android.1

IsCredentialsSavedResult

PropType
isSavedboolean

IsCredentialsSavedOptions

PropType
serverstring

SetDataOptions

PropTypeDescriptionDefaultSince
keystringUnique identifier for the stored value. Use a stable app-specific namespace (e.g. pin, session.token).
valuestringArbitrary string payload. Serialize objects with JSON.stringify() before storing. Platform limits apply: Android Keystore-backed encryption works best with payloads under ~8 KB; iOS Keychain practical limits are higher but very large values are discouraged.
accessControlAccessControlAccess control level for the stored value. When set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY, the value is hardware-protected and requires biometric authentication to access via getSecureData().AccessControl.NONE8.6.0
authValidityDurationnumberOnly for Android. Ignored on iOS and web. Only meaningful together with accessControl set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY.08.6.0
titlestringTitle for the biometric prompt shown while protecting data. Only for Android."Protect Data"8.6.0
negativeButtonTextstringText for the negative/cancel button in the biometric prompt. Only for Android."Cancel"8.6.0
maxAttemptsnumberSet a maximum number of attempts for biometric authentication. The maximum allowed by Android is 5. Only for Android.1

StoredData

PropType
valuestring

GetDataOptions

PropType
keystring

GetSecureDataOptions

PropTypeDescriptionDefault
keystring
reasonstringExplanation text shown as the subtitle of the Touch ID prompt. Face ID does not display it. Only for iOS.
titlestringTitle for the biometric prompt. Only for Android.
subtitlestringSubtitle for the biometric prompt. Only for Android.
descriptionstringDescription for the biometric prompt. Only for Android.
negativeButtonTextstringText for the negative/cancel button. Only for Android.
fallbackTitlestringSet the text for the fallback button in the authentication dialog. If this property is not specified, the default text is set by the system. Set it to an empty string to hide the button. Only for iOS.
maxAttemptsnumberSet a maximum number of attempts for biometric authentication. The maximum allowed by Android is 5. Only for Android.1

DeleteDataOptions

PropType
keystring

IsDataSavedResult

PropType
isSavedboolean

IsDataSavedOptions

PropType
keystring

Type Aliases

BiometryChangeListener

Callback type for biometry change listener

(result: AvailableResult): void

Enums

AuthenticationStrength

MembersValueDescription
NONE0No authentication available, even if PIN is available but useFallback = false
STRONG1Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android). Note: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true.
WEAK2Weak authentication: Face authentication on Android devices that consider face weak, or PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG).

BiometryType

MembersValue
NONE0
TOUCH_ID1
FACE_ID2
FINGERPRINT3
FACE_AUTHENTICATION4
IRIS_AUTHENTICATION5
MULTIPLE6
DEVICE_CREDENTIAL7

BiometricAuthError

MembersValueDescriptionSince
UNKNOWN_ERROR0Unknown error occurred
BIOMETRICS_UNAVAILABLE1Biometrics are unavailable (no hardware or hardware error) Platform: Android, iOS
USER_LOCKOUT2User has been locked out due to too many failed attempts Platform: Android, iOS
BIOMETRICS_NOT_ENROLLED3No biometrics are enrolled on the device Platform: Android, iOS
USER_TEMPORARY_LOCKOUT4User is temporarily locked out (Android: 30 second lockout) Platform: Android

版本与发布记录

@capgo/capacitor-native-biometric 共发布 80 个版本,首次发布于 2023/05/23;过去 12 个月发布了 53 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.9.1latest2026/10/2119 天前
8.9.02026/10/1821 天前
8.8.32026/10/1525 天前
8.8.22026/10/1327 天前
8.8.12026/10/091 个月前
8.8.02026/10/091 个月前

关于 @capgo/capacitor-native-biometric 的常见问题

@capgo/capacitor-native-biometric 是什么?

This plugin gives access to the native biometric apis for android and iOS

如何安装 @capgo/capacitor-native-biometric?

在项目目录运行 npm install @capgo/capacitor-native-biometric,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-native-biometric 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-native-biometric 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-native-biometric 可以商用吗?

@capgo/capacitor-native-biometric 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-native-biometric 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-native-biometric 在 2026/10/09 – 2026/11/07 这 30 天内被下载 972,225 次,日均约 32,408 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-native-biometric 还在维护吗?

最新版本 8.9.1 发布于 2026/10/21(19 天前);至今共发布 80 个版本,其中过去 12 个月发布了 53 个;首次发布于 2023/05/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。