React Native 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

Simple SDK Code Changes

If you are using Simple React-Native 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]

const initializeCallback = {
  onError(idwiseError) {
    console.log(
      'Event onInitalizeError:',
      idwiseError.code,
      idwiseError.message,
    );
  },
};

IDWise.initialize(clientKey,theme,initializeCallback);

Should be changed to be like this:

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

const initializeCallback = {
  onError(idwiseError) {
    console.log(
      'Event onInitalizeError:',
      idwiseError.code,
      idwiseError.message,
    );
  },
};
IDWise.initialize(clientKey,theme, initializeCallback);

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 the documentation.
  • The parameter journeyDefinitionId is now renamed to flowId
  • The parameter journeyCallback 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 

const applicantDetails = {};
applicantDetails[ApplicantDetailsKeys.FULL_NAME] = 'John Doe';
applicantDetails[ApplicantDetailsKeys.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 journeyCallback 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 method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyStartedInfo of type JourneyStartedInfo. The new type JourneyStartedInfo contains Journey Id as a subfield.

onJourneyResumed Callback Method

  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyResumedInfo of type JourneyResumedInfo. The new type JourneyResumedInfo contains Journey Id as a subfield.

JourneyFinished Callback Method

  • This delegate method is now named onJourneyCompleted
  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyCompletedInfo of type JourneyCompletedInfo. The new type JourneyCompletedInfo contains Journey Id and isCompleted as a subfields.

JourneyCancelled Callback Method

  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyCancelledInfo of type JourneyCancelledInfo. The new type JourneyCancelledInfo contains optional Journey Id as a subfield.

onError Callback Method

  • This method previously took one parameter of type IDWiseSDKError. But the type of this parameter was changed to become IDWiseError. It contains code and message as subfields.

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(data) {
      console.log('Event onError received:', data);
    },
  };

Should be changed to be like this:

 const journeyCallbacks = {
    onJourneyStarted(journeyStartedInfo) {
      console.log('Event onJourneyStarted received:', journeyStartedInfo);
    },
    onJourneyResumed(journeyResumedInfo) {
      console.log('Event onJourneyResumed received:', journeyResumedInfo);
    },
    onJourneyCompleted(journeyCompletedInfo) {
      console.log('Event onJourneyCompleted received:', journeyCompletedInfo);
    },
    onJourneyCancelled(journeyCancelledInfo) {
      console.log('Event onJourneyCancelled received:', journeyCancelledInfo);
    },
    onError(idwiseError) {
      console.log(
        'Event onError received:',
        idwiseError.code,
        idwiseError.message,
      );
    },
  };

Dynamic SDK Migration

If you are using Dynamic React Native 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 Hashmap of type String:String . You can pass this parameter as null 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:


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 

const applicantDetails = {};
applicantDetails[ApplicantDetailsKeys.FULL_NAME] = 'John Doe';
applicantDetails[ApplicantDetailsKeys.SEX] = 'male';

IDWiseDynamic.startJourney(
  flowId,
  referenceNo,
  locale,
  applicantDetails,
  journeyCallbacks,
  stepCallbacks
);

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 journeyCallback is now renamed to journeyCallbacks
  • The parameter stepCallback is now renamed to stepCallbacks

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: (summary) {
       print("onJourneySummary: $summary")
 });

Should be changed to become:

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

IDWiseSDK Journey Callbacks

JourneyStarted Callback Method

  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyStartedInfo of type JourneyStartedInfo. The new type JourneyStartedInfo contains Journey Id as a subfield.

onJourneyResumed Callback Method

  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyResumedInfo of type JourneyResumedInfo. The new type JourneyResumedInfo contains Journey Id as a subfield.

JourneyFinished Callback Method

  • This delegate method is now named onJourneyCompleted
  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyCompletedInfo of type JourneyCompletedInfo. The new type JourneyCompletedInfo contains Journey Id and isCompleted as a subfields.

JourneyCancelled Callback Method

  • This method previously took one parameter journeyInfo of type JourneyInfo but now the parameter changed to become journeyCancelledInfo of type JourneyCancelledInfo. The new type JourneyCancelledInfo contains optional Journey Id as a subfield.

onError Callback Method

  • This method previously took one parameter of type IDWiseSDKError. But the type of this parameter was changed to become IDWiseError. It contains code and message as subfields.

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(data) {
      console.log('Event onError received:', data);
    },
  };

Should be changed to be like this:

 const journeyCallbacks = {
    onJourneyStarted(journeyStartedInfo) {
      console.log('Event onJourneyStarted received:', journeyStartedInfo);
    },
    onJourneyResumed(journeyResumedInfo) {
      console.log('Event onJourneyResumed received:', journeyResumedInfo);
    },
    onJourneyCompleted(journeyCompletedInfo) {
      console.log('Event onJourneyCompleted received:', journeyCompletedInfo);
    },
    onJourneyCancelled(journeyCancelledInfo) {
      console.log('Event onJourneyCancelled received:', journeyCancelledInfo);
    },
    onError(idwiseError) {
      console.log(
        'Event onError received:',
        idwiseError.code,
        idwiseError.message,
      );
    },
  };


IDWiseSDK Step Callbacks

onStepCaptured Callback Method

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

onStepResult Callback Method

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

onStepCancelled Callback Method

  • This 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 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 subfield.

Code Implementation of Step Callbacks

//Declare global variables to be passed to initialize later
const stepCallback = {
    onStepCaptured(stepId, capturedImageB64) {
      console.log('Event onStepCaptured stepId:', stepId);
    },
    onStepResult(stepId, stepResult) {
      console.log('Event onStepResult stepId:', stepId);
      console.log('Event onStepResult stepResult:', stepResult);
    },
    onStepCancelled(stepId) {
      console.log('Event onStepCancelled stepId:', stepId);
    },
    onStepSkipped(stepId) {
      console.log('Event onStepSkipped stepId:', stepId);
    },
  };

should be changed to

//Declare global variables to be passed to initialize later
  const stepCallback = {
    onStepCaptured(stepCapturedInfo) {
      console.log('Event onStepCaptured stepId:', stepCapturedInfo.stepId);
    },
    onStepResult(stepResultInfo) {
      console.log('Event onStepResult stepId:', stepResultInfo.stepId);
      console.log('Event onStepResult stepResult:', stepResultInfo.stepResult);
    },
    onStepCancelled(stepCancelledInfo) {
      console.log('Event onStepCancelled stepId:', stepCancelledInfo.stepId);
    },
    onStepSkipped(stepSkippedInfo) {
      console.log('Event onStepSkipped stepId:', stepSkippedInfo.stepId);
    },
  };