windowMessageListener()
windowMessageListener()
is used to enable an Appsmith application to capture and react to the messages incoming from a parent application. This listener is page-scoped and is only active on the page where it's created.
Signature
windowMessageListener(domain: string, callback: function): Promise
Parameters
domain
A string that is the URL or domain of the website from which Appsmith expects to receive a message. The listener only listens for messages from the given domain when that domain is embedded in the Appsmith app; If the Appsmith app is embedded in some other website, the callback won’t be triggered.
If an active listener is already in place, it won't be overridden and a warning appears in the console. The use of the "*"
wildcard is not allowed in this parameter, a specific web address is required.
callback
A callback function to be called whenever a message is received from the target domain. It accepts a parameter that is the incoming message.
Example:
windowMessageListener(
"https://your-site.github.io",
(message) => { showAlert(message) }
)