Skip to content

Commit

Permalink
docs: update readme and blog
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelyCpp committed Oct 5, 2023
1 parent 6c95330 commit 8c7c519
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 18 deletions.
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,64 @@

![npm](https://img.shields.io/npm/v/react-native-simple-biometrics?color=%231F7AE0)

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.
## Overview

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.

![demo](./demo.gif?raw=true "demo")

## Getting started
## Installation

To get started with React Native Simple Biometrics, you can add it to your project using Yarn:

`$ yarn add react-native-simple-biometrics`
```bash
$ yarn add react-native-simple-biometrics
```

## minimum versions
## Minimum Requirements

- iOS target: `8.0`
- Android minSdkVersion: `21`

## iOS permission
## iOS Permission

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.
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:

```
```xml
<key>NSFaceIDUsageDescription</key>
<string>a valid reason to use biometrics</string>
```

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)
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.

## Usage

Only 2 methods are exposed
React Native Simple Biometrics offers two main methods:

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.

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.

- `canAuthenticate()`
- `requestBioAuth(promptTitle: string, promptMessage: string)`
Here's a code snippet demonstrating how to use these methods:

```javascript
import RNBiometrics from "react-native-simple-biometrics";

// this will be false if
// - no biometrics hardware
// - permission was denied for face ID (iOS only)
// Check if biometric authentication is available
const can = await RNBiometrics.canAuthenticate();

if (can) {
try {
await RNBiometrics.requestBioAuth("prompt-title", "prompt-message");
// stuff to do when authenticated
// Code to execute when authenticated
// ...
} catch (error) {
// stuff to do when auth failed
// Code to handle authentication failure
// ...
}
}
```

## credits
## Credits

[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.
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.
75 changes: 75 additions & 0 deletions blog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Elevating Security in React Native Apps with react-native-simple-biometrics


In today's digital age, security is paramount, especially for mobile applications that handle sensitive user data. One crucial aspect of mobile app security is biometric authentication, and the "react-native-simple-biometrics" library can enable just this! In this blog post, we will explore the usage of "react-native-simple-biometrics" and how it can enhance security in your React Native applications.

## Understanding Biometric Authentication

Biometric authentication involves using unique physical or behavioral characteristics of an individual to verify their identity. Common biometric methods include fingerprint recognition, facial recognition, and voice recognition. These methods provide a more secure and convenient way for users to access their devices or applications compared to traditional PINs or passwords.

## Benefits of Biometric Authentication in Mobile Apps

1. **Enhanced Security:** Biometric authentication methods are difficult to forge or mimic, making them highly secure.

2. **User Convenience:** Biometric authentication offers a frictionless user experience, reducing the need for remembering complex passwords.

3. **Quick Access:** Users can access their accounts or sensitive data quickly with a simple scan of their biometric features.

## Introducing react-native-simple-biometrics

React Native provides numerous libraries and plugins to extend its functionality, and "react-native-simple-biometrics" is one such package. It simplifies the integration of biometric authentication into your React Native applications.

### Key Features:

1. **Cross-Platform Compatibility:** "react-native-simple-biometrics" supports both iOS and Android platforms, ensuring broad compatibility.

2. **Fingerprint and Face Recognition:** The library supports fingerprint and facial recognition, allowing developers to choose the most suitable biometric method for their app.

3. **Simple Integration:** The library is easy to integrate into your React Native project, thanks to clear documentation and straightforward API calls.

4. **Customization:** Developers can customize the appearance and behavior of the biometric prompt to match the app's design and user experience.

## How to Use react-native-simple-biometrics

Now, let's dive into the practical aspect of implementing biometric authentication using "react-native-simple-biometrics." Follow these steps to get started:

### Step 1: Install the Package

You can install the library using npm or yarn:

```bash
npm install react-native-simple-biometrics --save
```

### Step 2: Import the Module

Import the "react-native-simple-biometrics" module in your JavaScript file:

```javascript
import Biometrics from 'react-native-simple-biometrics';
```

### Step 3: Implement Biometric Authentication

You can now implement biometric authentication in your app by calling the appropriate method. Here's an example of how to use fingerprint authentication:

```javascript
const canAuthenticate = await Biometrics.canAuthenticate();

if (canAuthenticate) {
try {
await Biometrics.requestBioAuth("prompt-title", "prompt-message");
// User authentication successful
// ...
} catch (error) {
// User authentication failed
// ...
}
}
```

## Conclusion

Incorporating biometric authentication into your React Native applications is a significant step towards enhancing security and user experience. The "react-native-simple-biometrics" library simplifies the process, making it accessible to developers of all skill levels.

By leveraging the power of biometrics, you can ensure that your users' data remains secure while providing a seamless and convenient login experience. So, give "react-native-simple-biometrics" a try in your next project and take your app's security to the next level!

0 comments on commit 8c7c519

Please sign in to comment.