Skip to main content

Iframe integration

Initial steps​

Embed the Gateway in an <iframe> to keep onboarding on your domain.

<iframe allow="camera" src="{{ onboardingUrl }}"></iframe>

The <iframe> src is the onboardingUrl that your backend received when it created the process.

Include camera in allow so the browser can ask the user for access to the camera; add microphone only for the recording video flow. The user must grant the requested permissions.

The Gateway sends Info and Error messages to the parent window via postMessage. Verify the sender's origin before handling them.

Informative events​

Global6 events
  • OnboardingStartedThe user started onboarding.
  • PlatformCheckStartedChecking browser and OS support.
  • PlatformCheckFinishedPlatform check finished.
  • HardwareCheckStartedChecking camera and, if needed, microphone.
  • HardwareCheckFinishedHardware check finished.
  • OnboardingFinishedOnboarding finished; Gateway redirects to a valid redirectUrl, if set.
Document6 events
  • DocumentSelectionStartedDocument selection shown.
  • DocumentSelectionFinishedThe user selected a document type.
  • DocumentInstructionsStartedCapture instructions shown.
  • DocumentInstructionsFinishedThe user continued to capture.
  • DocumentDetectionStartedCamera opened for document detection.
  • DocumentDetectionFinishedAll required document sides captured.
Face4 events
  • FaceInstructionsStartedFace capture instructions shown.
  • FaceInstructionsFinishedThe user continued to capture.
  • FaceDetectionStartedCamera opened for face capture.
  • FaceDetectionFinishedFace capture finished.
Recording video4 events
  • VideoRecordingInstructionsStartedVideo instructions shown.
  • VideoRecordingInstructionsFinishedThe user continued to recording.
  • VideoRecordingStartedVideo recording started.
  • VideoRecordingFinishedVideo recording finished.

Example listener:

window.addEventListener("message", (event) => {
// Security: validate the sender's origin; check event.source too if multiple iframes are present.
if (event.origin !== new URL(onboardingUrl).origin) return;
const { onboarding, type, value } = event.data;
if (type === "Info") {
const { name } = value;
const { scanId } = onboarding;
// Handle the event.
if (name === "OnboardingFinished") {
// Ask your backend for the result using the scanId.
}
}
});

When the process ends, the Gateway sends the OnboardingFinished event and redirects to the process redirectUrl, if one was set.

Take the decision in your backend

OnboardingFinished does not mean the user passed verification. Retrieve the process result and check the status and validations.

Error events​

Error events stop the flow. extraInfo may include a specific cause or failedValidations.

ConnectionErrorThe user's device does not have a stable network connection or is not available.2 causes
  • FetchTimeoutErrorSome of the calls made to the server have exceeded the maximum time allowed.
  • LowNetworkQualityErrorThe network quality is not enough to perform the process.
HardwareErrorThe user's device does not have a camera and/or microphone (if necessary), or is not available for use due to a hardware problem.3 causes
  • CameraDeviceErrorThe user's camera is not accessible by the browser (generic hardware error).
  • CameraNotAvailableErrorThe user's device does not have a camera.
  • CameraNotReadableErrorThe user's camera is in use by another process and cannot be accessed.
OnboardingErrorThe onboarding process was canceled because of a problem.3 causes
  • ClassificationErrorThe document could not be classified or is not allowed for onboarding.
  • FetchErrorA communication error occurred with the server.
  • ValidationErrorThe user did not pass an enabled document or face validation.
PermissionErrorThe user has not granted access to the camera and/or microphone, if required.2 causes
  • CameraNotAllowedErrorThe user has not granted camera access.
  • MicrophoneNotAllowedErrorThe user has not granted microphone access, if required.
SupportErrorAn unexpected error prevented onboarding from completing. Contact support.
TimeoutErrorThe user exceeded the maximum time allowed for onboarding.
TokenErrorThe onboarding identifier has expired and is no longer valid.1 cause
  • ScanIdErrorThe user is trying to reuse an identifier.

Error listener example:

window.addEventListener("message", (event) => {
// Security: validate the sender's origin; check event.source too if multiple iframes are present.
if (event.origin !== new URL(onboardingUrl).origin) return;
const { type, value } = event.data;
if (type === "Error") {
const { name, extraInfo: { cause, failedValidations } } = value;
// Handle the error, and in some cases the cause and failed validations.
}
});