Sample Project

You can find the sample project for the sample code for Cordova Integration.

1. Prerequisite

1.1 Android

The minSdkVersion is 21 and targetSdkVersion is set to 31 in IDWise Android SDK. It is recommended to install the Latest Android Studio on your development machine.

Build Setup

Add the following to your app-level build.gradle file located at projectRoot/android/app/build.gradle

android {
  ...
  defaultConfig {
    ...
    multiDexEnabled true
  }
  buildFeatures {
    ...
    dataBinding true
  }
}

Please Double check that mavenCentral() is added in your repositories, which is added by default if you create the new Cordova Project.

repositories {
  ...
  mavenCentral()
}

1.2 iOS

The minimum deployment target for IDWiseSDK is iOS 12.0. To use the SDK your application's minimum deployment target should be iOS 12.0 or higher.

2. Installation

Add the IDWiseSDK Plugin to your Cordova project by running the following command in the root project

cordova plugin add idwise-cordova-sdk

3. Cordova Usage

Invoking IDWise SDK is very simple. Follow the following steps to initialize and start the verification process

3.1 Initializing the SDK

In order to use the SDK, we need to initialize it first with the <CLIENT_KEY> provided by IDWise and your preffered theme. Here is how we can initialize the SDK.


function error(error) {
   //error callback for errors occured in initialize
    console.log(
      "onError :",
      error.errorCode,
      error.message
    );
}

var clientKey = "CLINT_KEYE"; //provided by IDWise
var theme = "SYSTEM_DEFAULT"; //available values: LIGHT, DARK, SYSTEM_DEFAULT

IDWise.initialize(clientKey, theme, error);

initializeSDK method takes two parameters and one callback:

  • clientKey: is a key provided to you by IDWise to authenticate your app with IDWise backend.
  • theme: Theme of the IDWise's UI, Available options are "DARK", "LIGHT", and "SYSTEM_DEFAULT"

3.2 Starting the Journey

Now we can start the verification journey by calling thestartJourney(..) of the SDK like below. This will start the verification process and that's it.

var flowId = "flow_id"; //aka journey definition id
var referenceNo = "referenceNo";
var locale = "en";

IDWise.startJourney(flowId,referenceNo, locale, journeyCallback);

This method takes the following parameters:

  • flowId: (also called Journey Definition ID) This is a unique identifier that identifies your journey flow. IDWise shares this with you when you register to use IDWise system.
  • referenceNo: (Optional) This parameter allows you to attach a unique identifier (such as a reference number) with the user undergoing the current journey. It's beneficial for connecting the journey to the user and/or the application that initiated it. You will receive this reference number in the webhook request.
  • locale: (Optional)This refers to the ISO code representing the desired language for the user interface components. Please reach out to IDWise IDWise Support for the list of available languages.
  • journeyCallback: This is an implementation of an interface that consists of various step callback events.

3.3 Journey (Callbacks)

Throughout the journey, IDWise SDK sends back some events to the Hosting app. Here we can listen to those events:

const journeyCallback = {
    onJourneyStarted(journeyInfo) {
      console.log(`Journey Started with id ${journeyInfo.journeyId}`);
    },
    onJourneyResumed(journeyInfo) {
      console.log(`Journey Resumed with id ${journeyInfo.journeyId}`);
    },
    onJourneyCompleted(journeyInfo) {
      console.log(`Journey Fininshed with id ${journeyInfo.journeyId}`);
    },
    onJourneyCancelled(journeyInfo) {
      console.log(`Journey Cancelled with id ${journeyInfo.journeyId}`);
    },
    onError(error) {
      console.log(
        "Event onJourneyError received:",
        error.errorCode,
        error.message
      );
    },
};

The journeyId, received in onJourneyStarted, can then be used by your backend code to securely get the result of the ID verification.