Flutter SDK Migration Guide

๐Ÿ“˜

Info

We strongly recommend using the latest version of IDWise SDK. This ensures you always have access to the latest improvements, bug fixes, and security updates.

Migrating from v4.x.x to v5.x.x

Required Imports

  • The import statement is changed in the latest version.

The following code:

import 'package:idwise_flutter_sdk/idwise_flutter.dart';

Should be changed to be like this:

import โ€˜package:idwise_flutter_sdk/idwise.dartโ€™;

Simple SDK Code Changes

If you are using Simple Flutter SDK integration please follow the following sections to change your code to be compatible with the new version:

IDWise.initialize method:

  • The theme parameter has its type changed from IDWiseSDKTheme to IDWiseTheme
    The following code:
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);
  });

Should be changed to be like this:

val clientKey = "<YOUR_CLIENT_KEY>"
val theme = IDWiseTheme.SYSTEM_DEFAULT //[LIGHT, DARK, SYSTEM_DEFAULT]

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

IDWise.startJourney method:

  • This method now takes a new optional parameter named applicantDetails which is a String:String dictionary. You can pass this parameter as nil if you do not intend to use it. For further information, please check documentation.
  • The parameter journeyDefinitionId is now renamed to flowId
  • The parameter journeyDelegate is now renamed to journeyCallbacks

The following code:

 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}'.");
  }

Should be changed to become:

String flowId = "<FLOW_ID>"
String referenceNo = "Unique reference number"; //[Optional] User's unique id e.g user_id
String locale = "en"; //Language code e.g en, ar 
Map<String, String> applicantDetails = HashMap();
      applicantDetails["full_name"] = "Waqar Khan";
      applicantDetails["sex"] = "Male";
     
try {
     IDWise.startJourney(flowId, referenceNo, locale,applicantDetails, journeyCallbacks);
  } on PlatformException catch (e) {
      print("Error : '${e.message}'.");
  }

IDWise.resumeJourney method:

  • The parameter journeyDefinitionId parameter is now renamed to flowId
  • The parameter journeyDelegate is now renamed to journeyCallbacks

The following code:

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 

IDWise.resumeJourney(journeyDefinitionId,journeyId,locale,journeyCallbacks);

Should be changed to become:

val flowId = "<FLOW_ID>"
val locale = "en"
val journeyId = "<YOUR_JOURNEY_ID>"


IDWise.resumeJourney(
  context,flowId,journeyId,locale,journeyCallbacks
)

IDWiseSDK Journey Callbacks

JourneyStarted Callback Method

  • This delegate method previously took one parameter journeyID: String but now the parameter changed to become journeyStartedInfo: IDWiseSDK.JourneyStartedInfo. The new type JourneyStartedInfo contains Journey Id as a sub field.

onJourneyResumed Callback Method

  • This delegate method previously took one parameter journeyID but now the parameter changed to become journeyResumedInfo: JourneyResumedInfo. The new type JourneyResumedInfo contains Journey Id as a sub field.

JourneyFinished Callback Method

  • This delegate method is now named onJourneyCompleted
  • This delegate method previously took one parameter journeyID: String but now the parameter changed to become journeyCompletedInfo: JourneyCompletedInfo. The new type JourneyCompletedInfo contains Journey Id as a sub field.

JourneyCancelled Callback Method

  • This delegate method previously took one parameter journeyID: String but now the parameter changed to become journeyCancelledInfo: JourneyCancelledInfo. The new type JourneyCancelledInfo contains Journey Id as a sub field.

onError Callback Method

  • This delegate method previously took one parameter of type IDWiseSDKError. But the type of this parameter was changed to become IDWiseError

Code Implementation of Journey Callbacks

The following code:

//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);
  }
};

Should be changed to be like this:

IDWiseJourneyCallbacks _journeyCallbacks = IDWiseJourneyCallbacks(
    onJourneyStarted: (dynamic journeyStartedInfo) {
      print("Method: onJourneyStarted, $journeyStartedInfo");
    },
    onJourneyCompleted: (dynamic journeyCompletedInfo) =>
        print("onJourneyCompleted: $journeyCompletedInfo"),
    onJourneyCancelled: (dynamic journeyCancelledInfo) =>
        print("onJourneyCancelled: $journeyCancelledInfo"),
    onJourneyResumed: (dynamic journeyResumedInfo) {
      print("Method: onJourneyResumed, ${journeyResumedInfo["journeyId"]}");
    },
    onError: (dynamic error) => print("onError $error"));

Dynamic SDK Migration

If you are using Dynamic Flutter SDK integration please follow the following sections to change your code to be compatible with the new version.

You should use IDWiseDynamic object to call methods in dynamic mode.

IDWise.initialize method:

  • The theme parameter has its type changed from IDWiseSDKTheme to IDWiseTheme
  • IDWiseDynamic should be used instead of IDWise to call this method.

The following code:

String clientKey = "<YOUR_CLIENT_KEY>"
IDWiseTheme theme = IDWiseSDKTheme.LIGHT //[DARK, LIGHT, SYSTEM_DEFAULT]

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

Should be changed to be like this:

String clientKey = "<YOUR_CLIENT_KEY>"
IDWiseTheme theme = IDWiseTheme.LIGHT //[DARK, LIGHT, SYSTEM_DEFAULT]

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

IDWise.startDynamicJourney method:

  • IDWiseDynamic should be used instead of IDWise to call this method.
  • This method is renamed from startDynamicJourney to startJourney.
  • This method now takes a new optional parameter named applicantDetails which is a String:String dictionary. You can pass this parameter as nil if you do not intend to use it. For further information, please check documentation.
  • The parameter journeyDefinitionId is now renamed to flowId
  • The parameter journeyDelegate is now renamed to journeyCallbacks

The following code:

IDWise.startDynamicJourney(journeyDefinitionId: "FLOW_ID", referenceNumber: "REFERENCE_NUMBER",locale: "LOCALE", journeyDelegate: self)

Should be changed to become:

Map<String, String> applicantDetails = HashMap();
      applicantDetails["full_name"] = "Waqar Khan";
      applicantDetails["sex"] = "Male";

IDWiseDynamic.startJourney(flowId:"FLOW_ID",
                           referenceNumber: "REFERENCE_NUMBER",
                           locale: "LOCALE", applicantDetails: applicantDetails,
                           journeyCallbacks: self)

IDWise.resumeDynamicJourney method:

  • IDWiseDynamic should be used instead of IDWise to call this method.
  • This method is renamed from resumeDynamicJourney to resumeJourney.
  • The parameter journeyDefinitionId parameter is now renamed to flowId
  • The parameter journeyDelegate is now renamed to journeyCallbacks

The following code:

let journeyDefinitionId = "<JOURNEY_DEFINITION_ID>" // aka flowId
let journeyId = "<YOUR_JOURNEY_ID>"
let locale = "en"

IDWise.resumeDynamicJourney(
 journeyDefinitionId,journeyId,locale, _journeyCallbacks,_stepCallbacks
);

Should be changed to become:

String flowId = "<FLOW_ID>"
String journeyId = "YOUR_JOURNEY_ID"
String locale = "en";
     
IDWiseDynamic.resumeJourney(
  flowId,journeyId, locale,journeyCallbacks,stepCallbacks
)

IDWise.finishDynamicJourney method:

  • IDWiseDynamic should be used instead of IDWise to call this method.
  • This method is renamed from finishDynamicJourney to finishJourney.

The following code:

IDWise.finishDynamicJourney()

Should be changed to become:

IDWiseDynamic.finishJourney()

IDWise.startStep method:

  • IDWiseDynamic should be used instead of IDWise to call this method.

The following code:

IDWise.startStep("STEP_ID")

Should be changed to become:

IDWiseDynamic.startStep("STEP_ID")

IDWise.skipStep method:

  • IDWiseDynamic should be used instead of IDWise to call this method.

The following code:

IDWise.skipStep("STEP_ID")

Should be changed to become:

IDWiseDynamic.skipStep("STEP_ID")

IDWise.unloadSDK method:

  • IDWiseDynamic should be used instead of IDWise to call this method.

The following code:

IDWise.unloadSDK()

Should be changed to become:

IDWiseDynamic.unloadSDK()

IDWise.getJourneySummary method:

  • IDWiseDynamic should be used instead of IDWise to call this method.

The following code:

IDWise.getJourneySummary(onJourneySummary: (dynamic summary) {
       print("onJourneySummary: $summary")
 });

Should be changed to become:

IDWiseDynamic.getJourneySummary(onJourneySummary: (dynamic summary) {
       print("onJourneySummary: $summary")
 });

IDWiseSDK Journey Callbacks

JourneyStarted Callback Method

  • This delegate method previously took one parameter journeyID: String but now the parameter changed to become journeyStartedInfo: IDWiseSDK.JourneyStartedInfo. The new type JourneyStartedInfo contains Journey Id as a sub field.

onJourneyResumed Callback Method

  • This delegate method previously took one parameter journeyID but now the parameter changed to become journeyResumedInfo: JourneyResumedInfo. The new type JourneyResumedInfo contains Journey Id as a sub field.

JourneyFinished Callback Method

  • This delegate method is now named onJourneyCompleted
  • This delegate method previously took one parameter journeyID: String but now the parameter changed to become journeyCompletedInfo: JourneyCompletedInfo. The new type JourneyCompletedInfo contains Journey Id as a sub field.

JourneyCancelled Callback Method

  • This delegate method previously took one parameter journeyID: String but now the parameter changed to become journeyCancelledInfo: JourneyCancelledInfo. The new type JourneyCancelledInfo contains Journey Id as a sub field.

onError Callback Method

  • This delegate method previously took one parameter of type IDWiseSDKError. But the type of this parameter was changed to become IDWiseError

Code Implementation of Journey Callbacks

The following code:

//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);
  }
};

Should be changed to be like this:

IDWiseJourneyCallbacks _journeyCallbacks = IDWiseJourneyCallbacks(
    onJourneyStarted: (dynamic journeyStartedInfo) {
      print("Method: onJourneyStarted, $journeyStartedInfo");
    },
    onJourneyCompleted: (dynamic journeyCompletedInfo) =>
        print("onJourneyCompleted: $journeyCompletedInfo"),
    onJourneyCancelled: (dynamic journeyCancelledInfo) =>
        print("onJourneyCancelled: $journeyCancelledInfo"),
    onJourneyResumed: (dynamic journeyResumedInfo) {
      print("Method: onJourneyResumed, ${journeyResumedInfo["journeyId"]}");
    },
    onError: (dynamic error) => print("onError $error"));

IDWiseSDK Step Callbacks

onStepCaptured Callback Method

  • This delegate method previously took two parameters stepId: Int and capturedImage: UIImage? but now the parameter changed to become stepCapturedInfo: StepCapturedInfo. The new type StepCapturedInfo contains stepId: String, originalImage: UIImage? and croppedImage: UIImage? as a subfields.

onStepResult Callback Method

  • This delegate method previously took two parameters stepId: Int and stepResult: StepResult? but now the parameter changed to become stepResultInfo: IDWiseSDK.StepResultInfo. The new type StepResultInfo contains stepId: String and stepResult: StepResult? as subfields.

onStepCancelled Callback Method

  • This delegate method previously took one parameter stepId: String but now the parameter changed to become stepCancelledInfo: StepCancelledInfo. The new type StepCancelledInfo contains stepId: String as a sub field.

onStepSkipped Callback Method

  • This delegate method previously took one parameter stepId: String but now the parameter changed to become stepSkippedInfo: StepSkippedInfo. The new type StepSkippedInfo contains stepId: String as a sub field.

Code Implementation of Step Callbacks

//Declare global variables to be passed to initialize later
late IDWiseSDKStepCallbacks _stepCallbacks;

_stepCallbacks = IDWiseSDKStepCallbacks(onStepCaptured: (dynamic response) {
      print("Method: onStepCaptured, ${response["stepId"]}");
      print("Method: capturedImage, ${response["capturedImage"]}");//base64 string   
    }, onStepResult: (dynamic response) {
      print("Method: onStepResult, $response");
    }, onStepCancelled: (dynamic response) {
      print("Method: onStepCancelled, $response");
    }, onStepSkipped: (dynamic response) {
      print("Method: onStepSkipped, $response");
    }
);

should be changed to

//Declare global variables to be passed to initialize later
late IDWiseSDKStepCallbacks _stepCallbacks;

_stepCallbacks = IDWiseStepCallbacks(onStepCaptured: (dynamic response) {
      print("Method: onStepCaptured, ${response["stepId"]}");
      print("Method: capturedImage, ${response["originalImage"]}");//base64 string   
       print("Method: capturedImage, ${response["croppedImage"]}");//base64 string   
    }, onStepResult: (dynamic response) {
      print("Method: onStepResult, $response");
    }, onStepCancelled: (dynamic response) {
      print("Method: onStepCancelled, $response");
    }, onStepSkipped: (dynamic response) {
      print("Method: onStepSkipped, $response");
    }
);