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:
IDWise.initialize
method:- The
theme
parameter has its type changed fromIDWiseSDKTheme
toIDWiseTheme
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:
IDWise.startJourney
method:- This method now takes a new optional parameter named
applicantDetails
which is aString:String
dictionary. You can pass this parameter asnil
if you do not intend to use it. For further information, please check documentation. - The parameter
journeyDefinitionId
is now renamed toflowId
- The parameter
journeyDelegate
is now renamed tojourneyCallbacks
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:
IDWise.resumeJourney
method:- The parameter
journeyDefinitionId
parameter is now renamed toflowId
- The parameter
journeyDelegate
is now renamed tojourneyCallbacks
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
JourneyStarted
Callback Method- This delegate method previously took one parameter
journeyID: String
but now the parameter changed to becomejourneyStartedInfo: IDWiseSDK.JourneyStartedInfo
. The new typeJourneyStartedInfo
contains Journey Id as a sub field.
onJourneyResumed
Callback Method
onJourneyResumed
Callback Method- This delegate method previously took one parameter
journeyID
but now the parameter changed to becomejourneyResumedInfo: JourneyResumedInfo
. The new typeJourneyResumedInfo
contains Journey Id as a sub field.
JourneyFinished
Callback Method
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 becomejourneyCompletedInfo: JourneyCompletedInfo
. The new typeJourneyCompletedInfo
contains Journey Id as a sub field.
JourneyCancelled
Callback Method
JourneyCancelled
Callback Method- This delegate method previously took one parameter
journeyID: String
but now the parameter changed to becomejourneyCancelledInfo: JourneyCancelledInfo
. The new typeJourneyCancelledInfo
contains Journey Id as a sub field.
onError
Callback Method
onError
Callback Method- This delegate method previously took one parameter of type
IDWiseSDKError
. But the type of this parameter was changed to becomeIDWiseError
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:
IDWise.initialize
method:- The
theme
parameter has its type changed fromIDWiseSDKTheme
toIDWiseTheme
IDWiseDynamic
should be used instead ofIDWise
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:
IDWise.startDynamicJourney
method:IDWiseDynamic
should be used instead ofIDWise
to call this method.- This method is renamed from
startDynamicJourney
tostartJourney
. - This method now takes a new optional parameter named
applicantDetails
which is aString:String
dictionary. You can pass this parameter asnil
if you do not intend to use it. For further information, please check documentation. - The parameter
journeyDefinitionId
is now renamed toflowId
- The parameter
journeyDelegate
is now renamed tojourneyCallbacks
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:
IDWise.resumeDynamicJourney
method:IDWiseDynamic
should be used instead ofIDWise
to call this method.- This method is renamed from
resumeDynamicJourney
toresumeJourney
. - The parameter
journeyDefinitionId
parameter is now renamed toflowId
- The parameter
journeyDelegate
is now renamed tojourneyCallbacks
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:
IDWise.finishDynamicJourney
method:IDWiseDynamic
should be used instead ofIDWise
to call this method.- This method is renamed from
finishDynamicJourney
tofinishJourney
.
The following code:
IDWise.finishDynamicJourney()
Should be changed to become:
IDWiseDynamic.finishJourney()
IDWise.startStep
method:
IDWise.startStep
method:IDWiseDynamic
should be used instead ofIDWise
to call this method.
The following code:
IDWise.startStep("STEP_ID")
Should be changed to become:
IDWiseDynamic.startStep("STEP_ID")
IDWise.skipStep
method:
IDWise.skipStep
method:IDWiseDynamic
should be used instead ofIDWise
to call this method.
The following code:
IDWise.skipStep("STEP_ID")
Should be changed to become:
IDWiseDynamic.skipStep("STEP_ID")
IDWise.unloadSDK
method:
IDWise.unloadSDK
method:IDWiseDynamic
should be used instead ofIDWise
to call this method.
The following code:
IDWise.unloadSDK()
Should be changed to become:
IDWiseDynamic.unloadSDK()
IDWise.getJourneySummary
method:
IDWise.getJourneySummary
method:IDWiseDynamic
should be used instead ofIDWise
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
JourneyStarted
Callback Method- This delegate method previously took one parameter
journeyID: String
but now the parameter changed to becomejourneyStartedInfo: IDWiseSDK.JourneyStartedInfo
. The new typeJourneyStartedInfo
contains Journey Id as a sub field.
onJourneyResumed
Callback Method
onJourneyResumed
Callback Method- This delegate method previously took one parameter
journeyID
but now the parameter changed to becomejourneyResumedInfo: JourneyResumedInfo
. The new typeJourneyResumedInfo
contains Journey Id as a sub field.
JourneyFinished
Callback Method
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 becomejourneyCompletedInfo: JourneyCompletedInfo
. The new typeJourneyCompletedInfo
contains Journey Id as a sub field.
JourneyCancelled
Callback Method
JourneyCancelled
Callback Method- This delegate method previously took one parameter
journeyID: String
but now the parameter changed to becomejourneyCancelledInfo: JourneyCancelledInfo
. The new typeJourneyCancelledInfo
contains Journey Id as a sub field.
onError
Callback Method
onError
Callback Method- This delegate method previously took one parameter of type
IDWiseSDKError
. But the type of this parameter was changed to becomeIDWiseError
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
onStepCaptured
Callback Method- This delegate method previously took two parameters
stepId: Int
andcapturedImage: UIImage?
but now the parameter changed to becomestepCapturedInfo: StepCapturedInfo
. The new typeStepCapturedInfo
containsstepId: String
,originalImage: UIImage?
andcroppedImage: UIImage?
as a subfields.
onStepResult
Callback Method
onStepResult
Callback Method- This delegate method previously took two parameters
stepId: Int
andstepResult: StepResult?
but now the parameter changed to becomestepResultInfo: IDWiseSDK.StepResultInfo
. The new typeStepResultInfo
containsstepId: String
andstepResult: StepResult?
as subfields.
onStepCancelled
Callback Method
onStepCancelled
Callback Method- This delegate method previously took one parameter
stepId: String
but now the parameter changed to becomestepCancelledInfo: StepCancelledInfo
. The new typeStepCancelledInfo
containsstepId: String
as a sub field.
onStepSkipped
Callback Method
onStepSkipped
Callback Method- This delegate method previously took one parameter
stepId: String
but now the parameter changed to becomestepSkippedInfo: StepSkippedInfo
. The new typeStepSkippedInfo
containsstepId: 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");
}
);
Updated 2 months ago