Flutter

This documentation will help you integrating IDWise SDK in your Flutter app.

📘

Sample Project

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

1. Requirements

1.1 iOS Requirements

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

1.2 Android Requirements

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.

2. Installation

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

flutter pub add idwise_flutter_sdk

3. Flutter Usage

Invoking IDWise SDK is very simple. First, import the IDWise package in your .dart file from where you want to invoke IDWise SDK:

3.1 Required Imports

import 'package:idwise_flutter_sdk/idwise_flutter.dart';

3.2 Initializing the SDK

In order to use the SDK, we need to initialize it first with the <CLIENT_KEY> provided by IDWise and a theme parameter. You can pre-load this on componentDidMount() if you want to. Here is how we can initialize the SDK.

void initializeIDWiseSDK() {
  String clientKey = "<clientKey>" //provided by IDWise
  String theme = IDWiseSDKTheme.LIGHT // Available options [DARK, LIGHT, SYSTEM_DEFAULT]

  IDWise.initialize(clientKey,theme, onError:(error){
     print("Error in initializeSDK");
     print(error);
  });
}

initializeSDK method takes two parameters:

  • 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.3 Start a new journey

Once the SDK is initialized, it becomes ready to start an ID verification journey flow. To commence the flow, the SDK offers a startJourney method, as demonstrated below.

//callbacks events for journey
const journeyCallback = {
  onJourneyStarted(data) {
    console.log('Event onJourneyStarted received:', data);
  },
  onJourneyResumed(data) {
    console.log('Event onJourneyResumed received:', data);
  },
  onJourneyFinished(data) {
    console.log('Event onJourneyFinished received:', data);
  },
  onJourneyCancelled(data) {
    console.log('Event onJourneyCancelled received:', data);
  },
  onError(error) {
    console.log('Event onError received:', error);
  }
};


void startJourney() {
  String journeyDefinitionId = "FLOW ID"; //As known as journey definition ID, Provided by IDWise
  String referenceNo = "Unique reference number"; //[Optional] User's unique id e.g user_id
  String locale = "en"; //Language code e.g en, ar 
    try {
        IDWise.startJourney(journeyDefinitionId,referenceNo,locale, journeyCallbacks);
    } on PlatformException catch (e) {
      print("Error : '${e.message}'.");
    }
}

This method takes the following parameters:

  • journeyDefinitionId: 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.

3.4 Callbacks

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

These are the supported events

  • onJourneyStarted: This event is triggered when a user's journey begins. It serves to notify your application that the process has been initiated. Useful for logging or implementing any preparatory actions necessary for the journey.
  • onJourneyFinished: This callback is activated upon the completion of a user's journey. It signifies that the user has successfully navigated through all steps and finished the process. This is typically where you would implement any code required to handle the completion of the journey.
  • onJourneyCancelled: This event is fired if the user decides to cancel the journey midway. It indicates the user's choice to discontinue the process. This could be useful for providing user-specific feedback or to trigger re-engagement strategies.
  • onError: This event is invoked when an error occurs at any point during the journey. It allows your application to respond to any unexpected issues, ensuring smooth error handling and user experience. Bellow all possible errors.

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

Here is a full sample of how to start an ID verification flow.


3.5 Resuming a Journey

If you want to resume an unfinished journey, you can do so as below:


void resumeJourney() {
  String journeyDefinitionId = "FLOW ID"; //As known as journey definition ID, Provided by IDWise
  String journeyId = "journey id"; //they journey id that you want to resume
  String locale = "en"; //Language code e.g en, ar 
    try {
        IDWise.resumeJourney(journeyDefinitionId,journeyId,locale,journeyCallbacks);
    } on PlatformException catch (e) {
      print("Error : '${e.message}'.");
    }
}

This method takes the following parameters:

  • journeyDefinitionId: Specifies the journey definition (aka template) to base this new journey on. Journey definitions are created based on your requirements and specify what documents and biometrics to collect from the user and in what order. JourneyDefinitionId is shared with you by IDWise team as part of your use-case and requirements discussions.
  • journeyId: This is a unique identifier that identifies your journey and it can be used to resume. This is received in the implementation of journeyCallback interface in onJourneyStarted method when you started the journey the first time.
  • locale : Language code of the language to be used to display the journey user interface. This is either an ISO 639-1 (2-letter for example en) or IETF BCP 47 (2-letter plus extended language specified for example zh-HK or zh-CN)
  • journeyCallbacks: This parameter is used to provide a set of event handlers to handle the different events that are triggered from IDWise SDK. These events indicate the lifetime of a journey and provide oppurtunity for your application to react to certain events. For more details please check Section 3.4
  • Once journey is resumed successfully, the event onJourneyResumed will be triggered.