Window postMessage API
LiSA supports safe cross-origin communication between the LiSA viewer app and embedding Window objects; e.g., with pages that embed the LiSA viewer app in an iFrame.
This article describes the messages and event actions that LiSA accepts and exposes.
LiSA utilizes the Window.postMessage APO event’s data object to pass information between windows. All messages relevant to LiSA implement the Message interface.
The Message interface provides information about the specific target and action of the event it represents, as well as sender and (optional) recipient information.
To receive messages from LiSA you need to add an event listener to your storefront, that listens for dispatched messages, sent by the LiSA viewer app. The message payload is accessed using the event's data property.
To only listen for messages sent by LiSA, please filter by sender as set in the payload's sender property. For messages from LiSA the value of that property will always be LiSA.
When sending messages to LiSA, please make sure to set the optional field recipient with value LiSA. Otherwise the message be ignored by the LiSA viewer app.
Here is an example message to revoke the like action on a carousel item:
Important: Please make sure to replace the targetOrigin parameter with your LiSA URL, or the wildcard *.
To enable logging of sent and received messages within the browser's console, please add query parameter debug=Messaging to your LiSA URL.