OkHi on your Android app

The suite of OkHi android 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

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

Androidx

Please make sure AndroidX is enabled in your project by modifying android/gradle.properties and adding 2 lines:

android.useAndroidX=true
android.enableJetifier=true

Add the JitPack repository to your build file

allprojects {
  repositories {
    ...
		maven { url 'https://jitpack.io' }
	}
}

Add the OkHi Core library dependencies

dependencies {
  implementation 'com.github.okhi:android-core:v1.3.1'
}

Check for the latest release on github.

Configure your app

​ Add ACCESS_FINE_LOCATION and ACCESS_BACKGROUND_LOCATION permissions to your AndroidManifest.xml

<manifest ...>

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

</manifest>

If you're targeting Android versions >= 8 you need to make sure your users select on "Allow always" when granting permissions otherwise the verification process won't work. See our best practices section

Authentication

Open your AndroidManifest.xml located under android/app/src/main/AndroidManifest.xml and add in your keys as shown bellow

<application>
    <meta-data android:name="io.okhi.core.branch_id" android:value="<my_branch_id>" />
    <meta-data android:name="io.okhi.core.client_key" android:value="<my_client_key>" />
    <meta-data android:name="io.okhi.core.environment" android:value="sandbox" /> <!-- set this to prod once ready to go live 🚀 -->
    <meta-data android:name="io.okhi.core.platform" android:value="android" />
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

See OkHi Core API reference here.

Last updated