指南
原生生物识别教程
使用@capgo/capacitor-native-biometric
该插件为 Android 和 iOS 提供原生生物识别 API
安装
bun add @capgo/capacitor-native-biometric
bunx cap sync
该插件暴露的内容
isAvailable- 检查生物识别硬件是否可用。verifyIdentity- 向用户提示使用生物识别进行身份验证。getCredentials- 获取给定服务器的存储凭据。setCredentials- 为给定的服务器存储给定的凭据。
示例用途
isAvailable
检查生物识别认证硬件是否可用。
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.isAvailable();
verifyIdentity
提示用户使用生物识别进行认证。
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.verifyIdentity();
getCredentials
获取给定服务器的存储凭据。
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.getCredentials({} as GetCredentialOptions);
setCredentials
为给定的服务器存储给定的凭据。
import { NativeBiometric } from '@capgo/capacitor-native-biometric';
await NativeBiometric.setCredentials({} as SetCredentialOptions);
全局参考
- GitHub: https://github.com/Cap-go/capacitor-native-biometric/
- 文档: /docs/plugins/native-biometric/