I have an extension that communicates with another extension’s background page to get weather information. The send request part of the app looks like this (the extension Id is copy pasted from the extension page):
chrome.extension.sendRequest(extensionId, {condition: "weather"}, function(response) {
console.log("got response");
}
and the background page is like this (the important part that is):
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.condition == "weather"){
getWeather(function(responseWeather) {
console.log(responseWeather);
sendResponse({weather: responseWeather});
});
}
});
I do have a pop up page that tests this functionality and it works on the same extension, but i cannot get the cross extension part to work at all. It doesn’t print “got response” in the send request function.
Any help would be appreciated. Thanks
You have to use
onRequestExternalin order to receive cross-extension requests.