Skip to content

Latest commit

 

History

History
74 lines (49 loc) · 1.86 KB

File metadata and controls

74 lines (49 loc) · 1.86 KB

React Native Local Authentication Getting Started Guide

  1. Add rn-local-authentication to your dependencies
yarn add rn-local-authentication

or, for npm use

npm install rn-local-authentication --save
  1. Link native dependencies

2.1 react-native >= 0.60

Autolinking will take care of the link step, but for iOS, don't forget to run pod install in ios/ folder

If you haven't set up cocoapods yet, please refer to that article

2.2 react-native < 0.60

You have to call link command manualy:

react-native link rn-local-authentication

For manual linking, please refer to:

  1. Additional step for FaceID devices:

Important

Include the NSFaceIDUsageDescription key in your app’s Info.plist file if your app allows biometric authentication. Otherwise, authorization requests may fail.

  1. Import LocalAuthentication into your component

Minimal example with ios:

import React from 'react';
import LocalAuthentication from 'rn-local-authentication';

class MyComponent extends React.Component {
    componentDidMount() {
        LocalAuthentication.authenticateAsync({
            reason: "Please, authenticate!"
        }).then(response => {
            if (response.success) {
                Alert.alert("Authenticated successfully!");
            } else {
                Alert.alert("Something went wrong");
            }
        })
    }

    render() {
        return (<AnotherComponent />);
    }
}

Minimal example with android:

missing android

Next, check out Api Reference