Use this event to listen for messages from other extensions or web pages.
By default, an extension can receive messages from any other extension. However, the externally_connectable manifest key can be used to limit communication to specific extensions and enable communication with websites.
To send a message that is received by the onMessageExternal listener, use runtime.sendMessage(), passing the ID of the recipient in the extensionId parameter.
Along with the message itself, the listener is passed:
- a
senderobject giving details about the message sender - a
sendResponsefunction that the listener can use to send a response back to the sender.
This API can't be used in a content script.