When i console.log(chrome)
with google chrome browser i get certain properties but i find the 'runtime' property of chrome 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__()
so chrome.runtime is undefined.
and hence i am not able to 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 wrong after going through above link) that a web page can communicate with a chrome extension. But not able to make it up through when the extension is installed from chrome store, however working perfectly in case of extension installed from local directory.
i am providing externallyConnectable as :
"externally_connectable": { "matches": [ "*://local.mywebsite.com/*" ] }
I have included the externally_connectable with "matches" property.. Now when i load unpacked directory to install extension, my web page get chrome.runtime.. but when i install extension from chrome store, the same web page on same browser does not get chrome.runtime.. why so?? in the end i still dont have chrome.runtime on the page ://local.mywebsite.com/. help me out.