4

I'm working on a project that needs to use an extension that a customer must download and install, however my web page needs to communicate with the extension, so i use the documented way:

https://developer.chrome.com/extensions/runtime#method-sendMessage

chrome.runtime.sendMessage(string extensionId, any message, object options, function responseCallback)
{
    ...
}

This means i have to include the "extensionId" of an extension that only generates this code once its installed.

Doesn't this sound a little "cart before the horse"?

I have to explain this to our clients, how to go and get their extension ID, and some how apply it to this page in order for it to work? Its seems terribly clumsy, especially since i have have to set the permissions explicitly.

"externally_connectable": {
    "matches": ["*://mywebsite.com/*"]
  },

If I omit extensionId, it doesn't work. "Uncaught Error: Invalid arguments to connect"

Conrad de Wet
  • 477
  • 6
  • 15

1 Answers1

0

According to the link you posted, it says extensionId is optional and that it is "[t]he ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app." So it seems that it should still work even without the extension ID.

Having said that I noticed the same error on an extension I'm trying to debug, but it seems to be all working despite it. And when I add the extensionId the errors disappear. Might need to find a way to access the extensionId from within the extension.

Update: I successfully substituted in '@@extension_id'. See this.

herb
  • 103
  • 3