1
votes

I am working on a Chrome extension that needs to call a native application.

As per Google documentation, we are using the chrome.runtime.connectNative method. However in our extension, it seems that the chrome.runtime object has no method 'connectNative'. When we display the list of methods of the chrome.runtime object, we get the following list (printed by console.log("" + Object.getOwnPropertyNames(chrome.runtime));

getManifest,getURL,reload,requestUpdateCheck,connect,sendMessage,onConnect,onMessage,id

We are using Chrome 31.0.1650.63 on MacOS X 10.8.5 . We have also tried with Chrome Canary (version 34.0.1767.0 canary), we have the same error, with a slightly different list of methods for chrome.runtime: getManifest,getURL,setUninstallUrl,reload,requestUpdateCheck,connect,sendMessage,onConnect,onMessage,id

So, in both cases (regular Chrome and Chrome Canary), we don't have the 'connectNative' method.

This does not seem to be a permissions problem, our extension manifest does have "nativeMessaging" in the permissions attribute. When we click on the permissions link in the Chrome extension settings, we can see that the extension can "communicate with cooperating native applications".

(sorry I couldn't post screenshots or the full manifest, StackOverflow won't let me paste things that even remotely look like I'm posting an image since I don't have enough reputation....)

Are we missing something ?

1
How about posting the code in the question ? (E.g. the manifest, the script where you call chrome.runtime.connectNative etc). - gkalpak
for some reason, the code contains a lot of [] and makes stackoverflow believe that I am trying to post images.... might be a bug in their post sanitization code - user3159388
Are you properly formatting the code (i.e. indenting all code 4 additonal spaces so that SO recognises it as a code block) ? - gkalpak

1 Answers

2
votes

The list of properties of chrome.runtime you are getting indicates that your code is running as a content script. Most chrome.* APIs are not available to content scripts. They can only be used from background or event pages, popups, or other extension views you define. So you can use regular extension messaging from your content script to a background or event page, which in its turn can call your native app.