Expo React Native Guide
Learn about OkHi's integration for verifying addresses.
Last updated
Learn about OkHi's integration for verifying addresses.
Last updated
Make sure you are running an Android Expo development build. See how to enable development builds here.
To install the OkHi React Native library run the command bellow
If you haven't done this already, make sure you are running an android development build. You can achieve this by running the bellow command in your projects root directory.
At this point you should be able to navigate to android/
Add the following permissions to your AndroidManifest.xml
located under android/app/src/main/AndroidManifest.xml
FOREGROUND_SERVICE
is required if your app is targeting Android 14+
In your android/build.gradle
add the OkHi Maven repo to the list of repositories i.e
If you haven't done this already, make sure you are running a ios development build. You can achieve this by running the bellow command in your projects root directory.
At this point you should be able to navigate to ios/
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.
Add necessary permissions to your info.plist
file located under /ios/MyApp
Open your AppDelegate.mm
file located under ios/MyApp/AppDelegate.mm
and add the following lines
If you have your project running, stop it and run the bellow command. It'll install all the necessary pods.
Add the following initialisation code to your App.js
file in such a way that the code is executed whenever your app is opened.
Replace my_branch_id
and my_client_key
with the keys provided to you after sign up.
important: initialisation has to be done each time on app start and shouldn't have any blocking operations before it. See full integration example
Test
To confirm that initialisation is working as expected, the `init done
` log should be printed out in your console every time your app is opened.
Always use your phone number or a phone number you own during testing as a message will be sent to this number after an address is created.
We recommend that you persist the verification state of the user in your app local storage. This state can be used to ensure that a user may only verify a predefined number of addresses. Usually one address for most use cases.
If you'd like to only have physical verification done you can include verification types as part of the config
object that's passed to OkHiLocationManager
It's possible to have both physical and digital verification to run at the same time for a given address. Include both verification types as part of the array.
On the client/app, within your onSucess handler you can access both user and address information which you can use to transit securely to your servers. See the API reference for complete list of properties on user and location.
Once an address has been created and you've configured a webhook in the OkHi Customer Dashboard, you'll be able to receive updates regarding address verification in your backend, which you can use to enable certain services in your app. The OkHi Dashboard allows you to do much more; please see the full webhook documentation here.
Title | Scenario | How to test |
---|---|---|
Create an address | Address creation succeeds and verification is initiated | Launch OkHi's address manager via the button you created and create an address. A sticky notification appears on android. |
Dashboard | When verification is initiated, the address shows up on OkHi Dashboard | Check OkDash, you should see a list of all the addresses created. It takes ~3min for addresses to show up on OkDash |
Proof of address | When an address is verified, the webhook receives the status update and the app shows the correct verification status. A proof of address certificate is made available on OkDash. | Install your app on your personal device that you move around with and create your home address. Check okDash in 3 days for your proof of address certificate once your address has been verified. |
Business logic | When an address is verified or not, the correct business logic is applied successfully. | Conduct a comprehensive test with multiple users, wherein they create various addresses to observe diverse outcomes. These outcomes may include successful creation of home addresses, entering incorrect addresses, refusing to grant necessary location permissions, or uninstalling the app immediately after initiating the address verification process, among other scenarios. |
API reference found here.
It is possible to completely transform the default appearance of OkHiLocationManager
to better match your brand by providing values to the theme
prop.
Once verification starts a persistent notification is visible (Android < 13). You can specify a custom default icon and a custom default color by adding these lines inside the application
tag to set the custom default icon and custom color. You'll need to have already created the icon resource in your android application. Icon assets can be created by following these steps
If your user created an address with OkHi and you have a valid OkHi locationId, pair of coordinates and user information such as a phone number, you can start verification without using the OkHiLocationManagerResponse object
If you have minifyEnabled
set to true
in your build.gradle
file located android/app/build.gradle
, you'll need to modify your proguard-rules.pro
file, located android/app/proguard-rules.pro
as shown bellow to include classes required by the library to run.
Submitting an app to Google Play store and App Store that has background location permissions has a few extra requirements. Follow these guide to know what to expect and how to handle the extra requirements:
Publishing to Google Play store
You may turn off either of the OkHi address types. This is to allow your users to create either home or work addresses to better suit your use-case. By default both address types are on.
For Addresses to be verified, the following requirements must be satisfied.
User grants background location permission for digital verification or when in use location permission for physical verification on both Android / iOS
Location services must be turned on both Android / iOS
Google Play Services must be available on Android
Luckily the OkHi library has helper methods to assist you with these requirements.
The request
function will go ahead and requests for background location permission as well as activate any services that might be offline. If you'd like a much fine grain control over how permissions are requested please see the API reference.
Make sure to go over our best practices doc requirement to make sure your application meets Play Store and App Store guidelines for requesting for background location permission.
OkVerify's foreground service improves the reliability and stability of verification signals coming from your user's Android device. Here's how to use it
Due to the Background Execution Limits introduced in Android 8 as well as restrictions imposed by some device manufacturers its become increasingly difficult to determine accurate and timely verification signals within android applications. In order to ensure reliability of these verification signals, the library comes with an opt-in foreground service that you can leverage to decrease the amount of time it takes to verify an address.
Configure a notification that'll be used to start the service. If you followed the previous guide, this should already be setup.
The foreground service is started by default once verification of an address starts, but can also be started again if previously stopped using the startForegroundService
function
Stopping the service is easy, simply make a call to the stopForegroundService
function
Stopping the foreground service does not stop verification of that address, the library will continue to use background services in order to obtain verification signals.
You can make a call to the isForegroundServiceRunning
function to determine whether a foreground service is present and running