Migrating to latest release

How to migrate to the latest release from @okhi/react-native libraries

To further improve both developer integration experience as well as library performance the latest release of OkHi React Native library combines all functionality of OkCollect & OkVerify into one single library. The library also comes with the much anticipated iOS support so you can finally start creating and verifying your iOS users.

Remove the current libraries

Remove the current OkHi libraries integrated in your project by running the script below

yarn remove @okhi/react-native-core @okhi/react-native-okcollect @okhi/react-native-okverify

Remove any installed pods

cd ios/ && pod install && cd../

Set your project up for the new library

iOS

Enable background mode in your application.

OkHi obtains verification signals in the background, to enable this make sure to add "Location updates" and "Background fetch" to your Background Modes under Signing & Capabilities of your target.

All OkHi react-native libraries target ios devices >= 12. Make sure you're targeting at-least the same by modifying your both your Podfile and deployment target.

Podile located under: ios/Podfile

platform :ios, '12.0'

Add necessary permissions to your info.plist file located under /ios/MyApp

<key>NSLocationWhenInUseUsageDescription</key>
<string>String that explains why you need when in use location permission</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>String that explains why you need always location permission</string>

Installation

Install the latest library by running

yarn add react-native-okhi

Finally install all required pods by running the following command in the ios directory

pod install

Initialization

Add the following initialization code to your index.js file. Replace my_branch_id and my_client_key with the keys provided to you after sign up.

import * as OkHi from 'react-native-okhi';

OkHi.initialize({
  credentials: {
    branchId: '<my_branch_id>',
    clientKey: '<my_client_key>',
  },
  context: {
    mode: 'sandbox',
  },
  notification: {
    title: 'Address verification in progress',
    text: 'Tap here to view your verification status.',
    channelId: 'okhi',
    channelName: 'OkHi Channel',
    channelDescription: 'OkHi verification alerts',
  },
})
  .then(() => console.log('init done'))
  .catch(console.log);

Remove previous OkVerify initialization

Address creation & verification

All existing exports from the previous libraries remain intact, all you have to do is import them from the new react-native-okhi library

Next steps

Check out the full guide

Checkout the API reference

Build a webhook endpoint to receive OkHi address verification scores.

OkHi integration best practices

Last updated