OkHi Documentation
  • 👋Welcome Home
  • OVERVIEW
    • OkHi Product Overview
    • Integration process overview
    • Verification terminology
    • Case Studies
  • Best Practices
    • Integration Best Practices
    • Live Examples
    • Tips for PMs & QA
      • Testing & QA Guide
      • Publishing to app stores
        • Google Play store
        • Apple App Store
    • Tips for designers
  • Code Libraries
    • Developer Quick Start
      • Environment setup
      • Release Notes
    • Android Guide
      • Android Dependencies
      • Migrating to the latest library
    • iOS Guide
    • React Native Guide
      • React Native Dependencies
      • React Native troubleshoot guide
    • Expo React Native Guide
    • Flutter Guide
      • Flutter Dependencies
    • JS library
      • API Reference
      • OkCollect Webhook
      • Changelog
    • WooCommerce Plugin
      • Changelog
  • Verification Status
    • Customer Dashboard
    • Verification Status Updates
      • Webhook v3
        • Webhook Signature Verification Guide
      • Webhook v2
      • Verification Status API
      • Proof Of Address Certificate API
      • FAQs
    • API reference docs
  • Troubleshooting
    • Error Responses
    • Common technical pitfalls
    • How to reduce "Unknowns"
    • FAQs
      • Technical FAQs
      • Compliance FAQs
    • Get in touch
Powered by GitBook
On this page
  • Change your compile SDK
  • Launch okCollect Function
  • OkHiUser
  • Start Verification Function
  • OkCollect.Builder

Was this helpful?

  1. Code Libraries
  2. Android Guide

Migrating to the latest library

How to migrate to the latest release

Our Android libraries have been updated to include the latest features from OkHi, such as the ability to pass your own system user IDs and enhanced security updates while providing a simpler and cleaner API.

Please follow these steps if you are using older library versions.

Change your compile SDK

The OkHi libraries target Android devices >= SDK 21. Make sure you've updated your compileSdkVersion & targetSdkVersion to 34 in your app/build.gradle file.

android {
    namespace = "io.okhi.okhiandroidverificationdemo"
    compileSdk = 34

    defaultConfig {
        applicationId = "io.okhi.okhiandroidverificationdemo"
        minSdk = 21
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"
    }
    buildTypes { ... }
    compileOptions { ... }
}
dependencies {
    implementation 'io.okhi.android:core:1.7.31'
    implementation 'io.okhi.android:okverify:1.9.66'
    implementation 'io.okhi.android:okcollect:3.3.45'
}

Within your AndroidManifest.xml , inside application , remove this line as it is no longer needed by our library.

<meta-data android:name="io.okhi.core.platform" android:value="android" />

Launch okCollect Function

The function has changed from this:

okCollect.launch(user, OkCollectLaunchMode.CREATE, new OkCollectCallback<OkHiUser, OkHiLocation>() {
    @Override
    public void onSuccess(OkHiUser okHiUser, OkHiLocation location) {
        startAddressVerification(okHiUser, location);
    }
    @Override
    public void onClose() {
        Toast.makeText(Sample.this, "User closed", Toast.LENGTH_LONG).show();
    }
    @Override
    public void onError(OkHiException e) {
        Toast.makeText(Sample.this, e.getCode() + ":" + e.getMessage(), Toast.LENGTH_LONG).show();
    }
});

To this which has one less parameter which is the removal of OkCollectLaunchMode.CREATE and OkCollectCallback that has also changed.

The onSuccess function has also been updated.

okCollect.launch(createOkHiUser(), new OkCollectCallback<OkCollectSuccessResponse>() {
    @Override
    public void onSuccess(OkCollectSuccessResponse response) {
      startAddressVerification(response);
    }
    
    @Override
    public void onClose() {
      showMessage("User closed.");
    }
    
    @Override
    public void onError(OkHiException e) {
      showMessage(e.getCode() + ":" + e.getMessage());
    }
});

To accessing the user and location properties, you do this:

OkHiUser user = response.getUser();
OkHiLocation location = response.getLocation();

OkHiUser

This builder has changed from this:

OkHiUser user = new OkHiUser.Builder("+234...")
        .withFirstName("Jane")
        .withLastName("Doe")
        .withEmail("jane@okhi.co") 
        .build();

To this which has the withAppUserId for passing your system's user ID if you want to pass it

OkHiUser user = new OkHiUser.Builder("+254...")
      .withFirstName("Jane")
      .withLastName("Doe")
      .withEmail("jane@okhi.co")
      .withAppUserId("abcd1234")
      .build();

Start Verification Function

The function has changed from this:

okVerify.start(user, location, new OkVerifyCallback<String>() {
    @Override
    public void onSuccess(String result) {
        Toast.makeText(Sample.this, "Started verification for: " + result, Toast.LENGTH_LONG).show();
    }

    @Override
    public void onError(OkHiException e) {
        Toast.makeText(Sample.this, e.getCode() + ":" + e.getMessage(), Toast.LENGTH_LONG).show();
    }
});

To this which has one less parameter which is all combined as a response.

okVerify.start(response, new OkVerifyCallback<String>() {
  @Override
  public void onSuccess(String locationId) {
    showMessage("Successfully started verification for: " + locationId);
  }

  @Override
  public void onError(OkHiException e) {
    showMessage(e.getCode() + ":" + e.getMessage());
  }
});

OkCollect.Builder

OkCollect.Builder no longer throws an exception so you don't need to wrap it in a try-and-catch.

//try {
    okhi = new OkHi(this);
    okCollect = new OkCollect.Builder(this).withTheme(theme).withConfig(config).build();
    okVerify = new OkVerify.Builder(this).build();
//} catch (Exception e) {
//    e.printStackTrace();
//}

PreviousAndroid DependenciesNextiOS Guide

Last updated 5 months ago

Was this helpful?