When I console.log(chrome) with google chrome browser I get certain properties, but I believe that the "runtime" chrome property is not available.
app: Object csi: function () { native function GetCSI(); return GetCSI();} loadTimes: function () { native function GetLoadTimes(); return GetLoadTimes();} webstore: Object __proto__: Object __defineGetter__: function __defineGetter__() { [native code] } __defineSetter__: function __defineSetter__() { [native code] } __lookupGetter__: function __lookupGetter__() { [native code] } __lookupSetter__: function __lookupSetter__() { [native code] } constructor: function Object() { [native code] } hasOwnProperty: function hasOwnProperty() { [native code] } isPrototypeOf: function isPrototypeOf() { [native code] } propertyIsEnumerable: function propertyIsEnumerable() { [native code] } toLocaleString: function toLocaleString() { [native code] } toString: function toString() { [native code] } valueOf: function valueOf() { [native code] } get __proto__: function __proto__() { [native code] } set __proto__: function __proto__()
therefore chrome.runtime is undefined.
and therefore I cannot use chrome.runtime.sendMessage for my extension
How to resolve the above?
EDIT:
my code is:
if(typeof(chrome) === 'undefined'){ result.isChromeBrowser = false; return next(result); } else { result.isChromeBrowser = true; } console.log(chrome.runtime); // undefined //check whether the chrome runtime is available or not ... if(!chrome.runtime){ result.isChromeRuntimeAvailable = false; console.log(result); } else { result.isChromeRuntimeAvailable = true; }
EDIT 2:
from here: https://developer.chrome.com/extensions/manifest/externally_connectable.html . I am sure (correct me if I am mistaken after following the link above) that the web page can link to the chrome extension. But it was not possible to execute it when the extension was installed from the chrome repository, however, it works fine if the extension is installed from the local directory.
I provide externallyConnectable as:
"externally_connectable": { "matches": [ "*://local.mywebsite.com/*" ] }
I have included externally_connectable with the "matches" property. Now, when I download the unpacked directory to install the extension, my web page receives chrome.runtime .. but when I install the extension from the chrome store, the same web page in the same browser does not receive chrome.runtime .. why so ?? in the end, I still don't have chrome.runtime on the page: //local.mywebsite.com/. help me.
source share