Callbacks
The iframe communicates with the host application by posting callback messages. Every callback has a stable shape and is delivered through a transport that depends on where the iframe is embedded.
Transports per platform
- Web: transport
window.postMessage; listenerwindow.addEventListener("message", ...). - iOS: transport webkit message handler (
bridge); listenerWKScriptMessageHandler. - Android: transport injected JS object (
legitHealthJsObject); listenerWebViewCompat.postWebMessage.
For the embedding code on each platform see the Platforms section.
Callback catalogue
analysis_completed: fires when the image has been processed and the report is ready. Payload includes theidof the report.invalid_company_key: fires when the iframe could not load because thecompanykey is invalid. Payload includes theid(the offending key).image_rejected: fires when an uploaded image fails the quality gate. Payload is apayload[]array with rejection reasons.
All three messages share the same envelope:
{
message: "<message_name>",
id: "<resource or key id>",
payload: <message-specific data> // when applicable
}
The pages that follow document each callback in detail along with the per-platform code you need to receive it.
Next Steps
- See platform-specific code? Go to the Platforms section.
- Ready to retrieve the report? See the Output → API Endpoint page.
- Want to process the results? See the Output section.