Flutter Dynamic SDK Integration

Dynamic journey implementation in Flutter

πŸ“˜

Sample Project

You can find the sample project for a complete Flutter Integration in dynamic mode.

If you require more control over the journey and order of the steps or show custom screens between ID verification steps, you can use IDWise SDK in dynamic mode. This mode allows you to start specific steps and for you application to regain control after each step. Please note this integration mode requires more code and responsibility on your side.

For an overview for end to end sequence diagram refer to Dynamic SDK Integration Overview.

Starting a new journey in dynamic mode

First ensure you have added the Flutter SDK dependency and initialize the SDK as in Step 1, Step 2 and Step 3.

Once the SDK is initialized, it becomes ready to start an ID verification journey flow. To commence the flow, articulated below methods are offer by SDK to start the journey in dynamic mode:

IDWise.startDynamicJourney(
	"<FLOW_ID>","<REFERENCE_NO>","en",_journeyCallbacks,_stepCallbacks
);

This method takes the following parameters and two callbacks:

  • 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 Supportfor the list of available languages.

Journey and Step Events (Callbacks)

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

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


_journeyCallbacks = IDWiseSDKJourneyCallbacks(
    onJourneyStarted: (dynamic journeyInfo) =>
        print("onJourneyStarted: $journeyInfo"),
    onJourneyCompleted: (dynamic journeyInfo) =>
        print("onJourneyCompleted: $journeyInfo"),
    onJourneyResumed: (dynamic journeyInfo) =>
        print("onJourneyResumed: $journeyInfo"),
    onJourneyCancelled: (dynamic journeyInfo) =>
        print("onJourneyCancelled: $journeyInfo"),
    onError: (dynamic error) => print("onError $error"));

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

Journey callback's usage are articulated below:

  • 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.
  • onJourneyResumed: This event is triggered when a user's journey resumes.
  • 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.

Step callback's usage is articulated below:

  • onStepCaptured: This event is triggered when a user captures an image or selects an image from a gallery. The purpose of this method is to handle the captured steps images.
  • onStepResult: This event is triggered with an outcome after the completion of a submission and process. This is typically where you may handle the results of your submitted step.
  • onStepCancelled: This event is triggered when the User cancels the step and the user is back in your app now.
  • onStepSkipped: This event is triggered in response to the IDWise.skipStep(stepId);method triggered once it is successful

Starting the Steps

When onJourneyStarted(...)or onJourneyResumed(...) are triggered successfully, you can call the IDWise.startStep(...) to start the specific verification Step.

IDWise.startStep(stepId);
  • stepId : ID of the step you want to start. (Will be provided by IDWise for each step)

The step events (provided in IDWiseSDKStepCallback parameter provided to startDynamicJourney or resumeDynamicJourney method) will be triggered as step is handled and processed.

Skipping a Step (Optional)

You can skip any step based on your business requirements by calling this method.

IDWise.skipStep(stepId);
  • stepId : ID of the step you want to skip, once successful, onStepSkipped(stepId) callback will be triggered.

The step events (provided in IDWiseSDKStepCallback parameter provided to startDynamicJourney or resumeDynamicJourney method) will be triggered as step is handled and processed.

Get Summary of the Verification Journey

You can get the Status of the journey anytime by calling the following function. You will receive the response against onJourneySummary event having the fields journeyId, journeyStepSummaries, journeyResult and journeyIsComplete.

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

JourneySummary contains the following information

FieldTypeDescription
journeyIdStringA unique identifier for the user journey.
isCompletedBooleanA boolean field that indicates if the journey is completed or not.
stepSummariesList of StepSummaryAn array of objects that detail the steps the user has gone through in the journey. Each object in this array contains a definition and a result.
journeyResultJourneyResultResult and Status of the verification Journey as described below

StepSummary contains the following information

FieldTypeDescription
definitionStepDefinitionAn object that describes the step.
resultStepResultAn object that contains the result of the step.

StepDefinition contains the following information

FieldTypeDescription
step_idIntAn identifier for the step within the journey.

JourneyResult contains the following information

FieldTypeDescription
completedStepsIntNumber of completed steps in the journey
interimRuleAssessmentInterimRuleAssessmentEnum for the combined Interim rules assessment result [Passed, Failed]
interimRuleDetailsHashMap<String, RuleDetail>Hashmap of all the Rules Assessment Results applicable

RuleDetail contains the following information

FieldTypeDescription
nameStringName of the Rule
resultResult of the Rule AssessmentEnum for the combined Interim rules assessment result [Passed, Failed, CouldNotApply]

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

Resuming a dynamic journey

IDWise.resumeDynamicJourney(
  "<FLOW_ID>","<JOURNEY_ID>","en", _journeyCallbacks,_stepCallbacks
);

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.
  • 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 journey first time.
  • locale: (Optional)This refers to the ISO code representing the desired language for the user interface components. Please reach out to IDWise Support for the list of available languages.
  • IDWiseSDKCallback: The implementation of the callback is in the preceding section.
  • IDWiseSDKStepCallback: The implementation of the callback is in the preceding section.

Finish Dynamic Journey

Once all necessary steps are concluded, you can finish the journey explicitly by calling this method

IDWise.finishDynamicJourney();

Unloading the SDK

You can unload the SDK when it is no longer required to free up the resources

IDWise.unloadSDK();