Iframe integration
Initial steps
Embed the Gateway in an <iframe> to keep the biometric operation on your domain.
<iframe allow="camera" src="{{ gatewayUrl }}"></iframe>
The <iframe> src is the gatewayUrl 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. The user must grant the permission.
The Gateway sends Info and Error messages to the parent window via postMessage. Verify the sender's origin before handling them.
Informative events
Global4 events
- ProcessStartedThe user started the process.
- PlatformCheckStartedChecking browser and OS support.
- PlatformCheckFinishedPlatform check finished.
- ProcessFinishedThe process finished. The Gateway redirects to the returnUrl, if one was set.
Face4 events
- FaceVerificationInstructionsStartedFace verification instructions shown.
- FaceVerificationInstructionsFinishedThe user continued from the instructions.
- FaceVerificationBiometricStartedBiometric face verification started.
- FaceVerificationBiometricFinishedBiometric face verification 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(gatewayUrl).origin) return;
const { processId, type, value } = event.data;
if (type === "Info") {
const { name } = value;
// Handle the event.
if (name === "ProcessFinished") {
// Ask your backend for the result of processId.
}
}
});
When the process ends, the Gateway sends the ProcessFinished event and redirects to the process returnUrl, if one was set.
Take the decision in your backend
ProcessFinished does not mean the user was verified. Retrieve the process result and check the status.
Error events
Error events stop the flow. extraInfo may include a specific cause.
BiometricErrorA problem occurred during the biometric operation.
ConnectionErrorThe user's device does not have a stable network connection.
HardwareErrorThe device has no camera or microphone (if needed), or it cannot be used.3 causes
- DeviceErrorThe browser cannot access the camera (generic hardware error).
- DeviceNotAvailableErrorThe device does not have a camera.
- DeviceNotReadableErrorThe camera is in use by another process.
PermissionErrorThe user has not granted access to the camera or microphone (if needed).1 cause
- DeviceNotAllowedErrorThe user has not granted access to the camera.
SupportErrorAn unexpected error occurred. Contact Mobbeel support.
TimeoutErrorThe user exceeded the maximum time set for the process.
TokenErrorThe process has expired and is no longer valid.
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(gatewayUrl).origin) return;
const { type, value } = event.data;
if (type === "Error") {
const { name, extraInfo: { cause } } = value;
// Handle the error, and in some cases the cause.
}
});