Latif Uluman
Latif Uluman

Reputation: 255

Send Message to Chrome Plugin From Website

I am developing a chrome plugin. I want to send message from a web site to plugin. I am following Google's offical documentation which is https://developer.chrome.com/apps/messaging#external-webpage. I do the same thing. The below code is from my manifest.json file.

  "externally_connectable": {
    "matches": ["<all_urls>"]
  },

Then I have added the following code to background.js file

chrome.runtime.onMessageExternal.addListener(
  function(request, sender, sendResponse) {
    alert("Message received")
  });

After reloading my extention, I am trying to send message from the console of a web site with the following code:

chrome.runtime.sendMessage(extentionId, {"name":"latif"},
  function(response) {
    if (!response.success)
      handleError(url);
  });

But I get an error like following:

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. Altough I search the error, I could not find a satisfied answer. What is wrong in here? Thank you..

Upvotes: 2

Views: 68

Answers (0)

Related Questions