Initial integration
...
Embed Plug-in
Embed in web app

Listening to message events

Introduction

This document describes how to listen for message events from the plug-in within your parent website's code. By doing so, you can monitor the user's progress within the plug-in and obtain the ID of the face scan the user performed. You will need the ID of the face scan to request Widgets or results via the API .

We cover the basic communication protocol between the plug-in iframe component and your website, which we refer to as the "parent website".

Do note that it is also possible to fetch the results at a later point in time. You can either request the plug-in's entire results screen (refer to Request results page URL) or just get the data using our Get results API endpoint.

Basic Concept

The plug-in iframe incorporates a mechanism that allows it to communicate message events with the parent website, i.e. your website. These can then be handled as needed. We use the browser postMessage feature to facilitate communication between the plug-in iframe component and the parent website.

The messages are sent at various stages, updating the parent website of the user's progress inside the plug-in.

Post Messages

The window.postMessage(), which our plug-in uses, is a method that safely enables communication between Window objects; for example between a page and an iframe embedded within it.

More info on the postMessage browser feature:

Browser Support

Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#browser_compatibility
Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#browser_compatibility


Set up Message Listener

The code below shows a basic example of how to let your parent website listen for post messages from the plug-in iframe component. Add the JS below to your website.

JS


Full example

HTML




Next steps

  • To learn more about the different types of messages the plug-in sends during a health check, refer to the Message events page.
  • To allow for seamless integration of the iframe in your website, matching your brand's colours and fonts, please visit our Customisation documentation.