Events

This document explains how to handle events emitted by the onboarding process using window.postMessage().

The Onboarding process communicates with an iFrame or WebView by emitting events through window.postMessage(). Event support is currently available for iFrame, Flutter*, and React Native.

Listening to the message Event:

To listen for messages emitted by the onboarding process, use the following code:

window.addEventListener(
  "message",
  function (e) {
    console.log(e.data);
  },
  false
);

Example of a Returned Message:

{
  "code": "ONBOARDING_FINISHED",
  "response": {
    "executionId": "xxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

Always listen to the "message" event, as communication with the onboarding link through an iFrame utilizes the postMessage API.

Using a Specific Event Code from Onboarding:

To handle specific event codes emitted by Onboarding, you can check the code property in the event data:

window.addEventListener(
  "message",
  function (e) {
    if (e.data.code === "SDK_BACK_CAPTURE_STARTED") {
      console.log("The capture was started");
    }
  },
  false
);

If using Web Message Listeners with Flutter, then InAppWebView should be used, with jsObjectName set as FutterOnboardingChannel

The events that can be issued by Onboarding are as follows:

  • SDK_CAPTURE_INVALID: Will be triggered when capture is invalid, such as an incorrect document or poor image quality. (Document Detector and Passive Face Liveness)

  • SDK_CAPTURE_FAILED: Some other failure in the capture. (Document Detector and Passive Face Liveness)

  • SDK_CAPTURE_RESULT: Result of the capture. (Liveness and FaceAuthenticator)

  • SDK_BACK_CAPTURE_STARTED: Started capturing the backside of the document (Document Detector)

  • SDK_FRONT_CAPTURE_STARTED: Started capturing the front of the document (Document Detector)

  • DD_CAPTURE_FINISH: Document Detector capture step in onboarding completed (If it has both sides, it will only be triggered when both sides are captured) in fact it is only triggered when you are already moving on to the next step, if everything is ok with the capture

  • ONBOARDING_FINISHED: Onboarding finished

Last updated

Logo

2023 © Caf. - All rights reserved