Saltar al contenido principal

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; listener window.addEventListener("message", ...).
  • iOS: transport webkit message handler (bridge); listener WKScriptMessageHandler.
  • Android: transport injected JS object (legitHealthJsObject); listener WebViewCompat.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 the id of the report.
  • invalid_company_key: fires when the iframe could not load because the company key is invalid. Payload includes the id (the offending key).
  • image_rejected: fires when an uploaded image fails the quality gate. Payload is a payload[] 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.