[英]Can't get chrome.runtime.onMessageExternal working between extensions
In extension with id aglpopilkbmccegiojppdmbhamchojed
I have in the background script 以id aglpopilkbmccegiojppdmbhamchojed
为扩展名,我在后台脚本中
chrome.runtime.onMessageExternal.addListener(function(request, sender, sendResponse) {
console.log(request);
}
In the other extension I have 在另一个扩展中,我有
chrome.runtime.sendMessage('aglpopilkbmccegiojppdmbhamchojed', 'dummymessage')
This isn't working. 这不起作用。 Do I need to add something to the manifest.json file? 我是否需要向manifest.json文件中添加一些内容? However, with an appropriate entry in the manifest file, I can send message from a web page. 但是,通过清单文件中的适当条目,我可以从网页发送消息。 Any clue why it might not be working? 任何线索为什么它可能无法正常工作?
Figured out that I did need to add to the manifest.json file. 弄清楚我确实需要添加到manifest.json文件。
The page at https://developer.chrome.com/extensions/messaging by mentioning the manifest file for sending messages from web pages but omitting to mention it for "Cross-extension messaging" mislead me. https://developer.chrome.com/extensions/messaging上的页面通过提及用于从网页发送消息的清单文件而忽略了“跨扩展消息传递”,从而误导了我。
Anyway adding following to manifest.json did it 无论如何,在manifest.json中添加了以下内容
"externally_connectable": {
"ids": ["*"],
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.