适用于 iOS 和 Android 生物识别的 React Native 模块
React Native 生物识别技术是通向原生 iOS 和 Android 键储管理的简单桥梁。 它允许您创建存储在原生键储中的公私密钥对,并通过生物识别身份验证进行保护。 这些密钥随后可以在正确身份验证后进行检索,并用于创建加密签名。
React-native-biometrics 版本 |
需要的 React Native 版本 |
|---|---|
>= 3.0.0 |
>= 0.60 |
| `{ | |
| const { available, biometryType } = resultObject |
if (available && biometryType === BiometryTypes.TouchID) { console.log('支持 TouchID') } else if (available && biometryType === BiometryTypes.FaceID) { console.log('FaceID 支持') } else if (available && biometryType === BiometryTypes.Biometrics) { console.log('支持生物识别') } else { console.log('不支持生物识别') } })
### createKeys()
Generates a public private RSA 2048 key pair that will be stored in the device keystore. Returns a `Promise` that resolves to an object providing details about the keys.
__Result Object__
| Property | Type | Description |
| --- | --- | --- |
| publicKey | string | A base64 encoded string representing the public key |
__Example__
js import ReactNativeBiometrics from 'React-native-biometrics' const rnBiometrics = new ReactNativeBiometrics() rnBiometrics.createKeys() ).then((resultObject) => { const { publicKey } = resultObject console.log(publicKey) sendPublicKeyToServer(publicKey) })
### biometricKeysExist()
Detects if keys have already been generated and exist in the keystore. Returns a `Promise` that resolves to an object indicating details about the keys.
__Result Object__
| Property | Type | Description |
| --- | --- | --- |
| keysExist | bool | A boolean indicating if keys exist in the keystore |
__Example__
js import ReactNativeBiometrics from 'React-native-biometrics' const rnBiometrics = new ReactNativeBiometrics() rnBiometrics.biometricKeysExist(
暂无开放 Issues,或尚未同步最近议题。