|
2 | 2 |
|
3 | 3 |  |
4 | 4 |
|
5 | | -A simple and straight forward API to ask a user to authenticate with on device biometrics. This can be used to quickly verify if the app is being used by the owner of the phone (or a trustee) before showing some sensitive info. |
| 5 | +## Overview |
| 6 | + |
| 7 | +React Native Simple Biometrics is a straightforward and minimalistic React Native package designed to provide developers with an API for implementing user authentication using on-device biometrics. This library facilitates the quick verification of the app's user, ensuring that sensitive information is only accessible to authorized individuals, such as the phone owner or a trustee. |
6 | 8 |
|
7 | 9 |  |
8 | 10 |
|
9 | | -## Getting started |
| 11 | +## Installation |
| 12 | + |
| 13 | +To get started with React Native Simple Biometrics, you can add it to your project using Yarn: |
10 | 14 |
|
11 | | -`$ yarn add react-native-simple-biometrics` |
| 15 | +```bash |
| 16 | +$ yarn add react-native-simple-biometrics |
| 17 | +``` |
12 | 18 |
|
13 | | -## minimum versions |
| 19 | +## Minimum Requirements |
14 | 20 |
|
15 | 21 | - iOS target: `8.0` |
16 | 22 | - Android minSdkVersion: `21` |
17 | 23 |
|
18 | | -## iOS permission |
| 24 | +## iOS Permission |
19 | 25 |
|
20 | | -It is required to add an entry in your ios app's `info.plist` giving a valid reason to use the phones face ID system. |
| 26 | +To utilize the Face ID system on iOS devices, it is mandatory to include an entry in your iOS app's `info.plist`, explaining the valid reason for using biometrics: |
21 | 27 |
|
22 | | -``` |
| 28 | +```xml |
23 | 29 | <key>NSFaceIDUsageDescription</key> |
24 | 30 | <string>a valid reason to use biometrics</string> |
25 | 31 | ``` |
26 | 32 |
|
27 | | -Calling the authenticate function will automatically ask iOS users for the permission. For more control over when to ask permissions, use [react-native-permissions](https://www.npmjs.com/package/react-native-permissions) |
| 33 | +When you call the `authenticate` function, iOS users will be automatically prompted for permission. For more granular control over when to request permissions, you can utilize the [react-native-permissions](https://www.npmjs.com/package/react-native-permissions) package. |
28 | 34 |
|
29 | 35 | ## Usage |
30 | 36 |
|
31 | | -Only 2 methods are exposed |
| 37 | +React Native Simple Biometrics offers two main methods: |
| 38 | + |
| 39 | +1. `canAuthenticate()`: Checks whether the device supports biometric authentication. Returns `true` if the hardware is available or if permission for Face ID (iOS) was granted. |
| 40 | + |
| 41 | +2. `requestBioAuth(promptTitle: string, promptMessage: string)`: Initiates the biometric authentication process, displaying a user-friendly prompt with the specified title and message. This function can be used for user authentication. |
32 | 42 |
|
33 | | -- `canAuthenticate()` |
34 | | -- `requestBioAuth(promptTitle: string, promptMessage: string)` |
| 43 | +Here's a code snippet demonstrating how to use these methods: |
35 | 44 |
|
36 | 45 | ```javascript |
37 | 46 | import RNBiometrics from "react-native-simple-biometrics"; |
38 | 47 |
|
39 | | -// this will be false if |
40 | | -// - no biometrics hardware |
41 | | -// - permission was denied for face ID (iOS only) |
| 48 | +// Check if biometric authentication is available |
42 | 49 | const can = await RNBiometrics.canAuthenticate(); |
43 | 50 |
|
44 | 51 | if (can) { |
45 | 52 | try { |
46 | 53 | await RNBiometrics.requestBioAuth("prompt-title", "prompt-message"); |
47 | | - // stuff to do when authenticated |
| 54 | + // Code to execute when authenticated |
48 | 55 | // ... |
49 | 56 | } catch (error) { |
50 | | - // stuff to do when auth failed |
| 57 | + // Code to handle authentication failure |
51 | 58 | // ... |
52 | 59 | } |
53 | 60 | } |
54 | 61 | ``` |
55 | 62 |
|
56 | | -## credits |
| 63 | +## Credits |
57 | 64 |
|
58 | | -[react-native-biometrics](https://www.npmjs.com/package/react-native-biometrics) is a super-set of this library. For more features like keys generation, signatures, etc use react-native-biometrics. |
| 65 | +React Native Simple Biometrics is a simplified version of [react-native-biometrics](https://www.npmjs.com/package/react-native-biometrics). If you require advanced features such as key generation, signatures, and more, consider using react-native-biometrics. |
0 commit comments