React Native

2 min read

Before start

Footprint provides an integration using React Native. The usage is similar to what we have on the web, but instead of using iframes, we use an in-app browser (webview).

Installation

  1. Install footprint-react-native:

bash

# With NPM
npm install @onefootprint/footprint-react-native

# With yarn
yarn add @onefootprint/footprint-react-native
  1. On iOS, make sure to have the native dependencies installed:

bash

cd ios
pod install

Integration

  1. Grab the Onboarding Publishable Key, for example ob_test_VMooXd04EUlnu3AvMYKjMW.

  2. Import the styles file and embed the Footprint button, passing the Publishable Key and the callback functions:

typescript

import { FootprintButton } from '@onefooprint/footprint-react-native';

import { View } from 'react-native';

const Screen = () => {
  const handleCompleted = (validationToken: string) => {
    console.log(validationToken);
  };

  const handleCanceled = () => {
    console.log('user canceled');
  };

  return (
    <View>
      <FootprintButton
        publicKey="ob_test_VMooXd04EUlnu3AvMYKjMW"
        onCompleted={handleCompleted}
        onCanceled={handleCanceled}
      />
    </View>
  );
};

Custom button

  1. Alternatively, you can open Footprint from a custom button:

typescript

import footprint from '@onefooprint/footprint-react-native';

import { View, Button } from 'react-native';

const Screen = () => {
  const handlePress = () => {
    footprint.open({
      publicKey: 'ob_test_VMooXd04EUlnu3AvMYKjMW',
      onCanceled: () => {
        console.log('user canceled');
      },
      onCompleted: (validationToken: string) => {
        console.log(validationToken);
      },
    });
  };

  return (
    <View>
      <Button title="Verify identity" onPress={handlePress} />
    </View>
  );
};

Click here to check out a full example.