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.

有帮助吗?

解决方案

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...)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top