OkHi on your React Native App

The suite of OkHi react native libraries that will enable you to start collecting and verifying your user's addresses.

tl;dr

To start verifying address you need to integrate two libraries. OkCollect & OkVerify.

  • OkCollect - enables you to launch OkHi from your app and collect accurate addresses from your users.

  • OkVerify - enables you to verify the addresses created from OkCollect.

The OkCollect & OkVerify libraries currently only supports Android devices with iOS support coming soon!

Prerequisites

OkHi Client Key and Branch Id

First you need to obtain your OkHi client key and branch ID. You can get these by signing up here.

Use your sandbox keys while you test and develop, and your production mode keys before you publish your app.

Installation

Install the OkHi Core module

$ yarn add @okhi/react-native-core

Configure your app

Android

​ Add the following permissions to your AndroidManifest.xml

<manifest ...>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    ...
    
    <application>
    ...
    </application>

</manifest>

If you're targeting Android versions >= 8 and you're using the OkVerify library you need to make sure your users select on "Allow always" when granting permissions otherwise the verification process won't work.

All OkHi react-native libraries target android devices >= SDK 23. Make sure you're targeting at-least the same by modifying your android/build.gradle file

ext {
  minSdkVersion = 23
  ..//
}

iOS

​ Make sure to include the following permissions in your info.plist file ​

<key>NSLocationWhenInUseUsageDescription</key>
<string>Add description here</string>

Initialization

Create a file and configure your OkHiAuth object

$ touch OkHiAuth.js

Place the following code in OkHiAuth.js and change the values as needed

import {OkHiAuth, OkHiContext, OkHiMode} from '@okhi/react-native-core';

const context = new OkHiContext({
  mode: OkHiMode.SANDBOX,
  app: {
    build: 1,
    name: 'My App',
    version: '1.0.0',
  },
});

export default OkHiAuth.withContext({branchId: "<my_branch_id>", clientKey: "<my_client_key>"}, context);

See OkHi Core API reference here.

Last updated