Working example of chrome extension with native app messaging

1.7k views Asked by At

I am trying out Chrome's native messaging API but I haven't been able to get it to work.

The documentation has a link to this example, but it's not an example of an extension, it's a chrome packaged app.

I've tried modifying it to work as an extension, but I lack the experience to get it right.

Can someone please give me an example of a chrome extension that can work with a native app?

Thank you.

1

There are 1 answers

8
gkalpak On BEST ANSWER

Luckily, the example you link to is fairly simple and does not use any app-specific API.
Thus, it should be easy to convert it to an extension by slightly modifying the manifest:

// Replace that:
"app": {
    ...
},

// With this:
"browser_action": {
    "default_title": "Test Extension",
    //"default_icon": {
    //    "19": "img/icon19.png",
    //    "38": "img/icon38.png"
    //},
    "default_popup": "main.html"
},

(I haven't tested it myself, but it should work...)