I am working on native messaging host. I am able to launch my custom application by using api
var port = chrome.runtime.connectNative(\'com.my_company.my_app
UPDATE:
Regarding how to listen for the messages on the native app, they are sent to the stdio (for the time being this is the only available communication channel between Chrome extensions and native apps). Take a look at this sample app featuring a native messaging host implemented in python.
You listen for messages registering a listener on port's onMessage event.
Use sendNativeMessag() only if you want a one-time communication (not a persistent port). In that case, do not use chrome.runtime.connectNative(...). Instead, do something like this:
var msg = {...};
chrome.runtime.sendNativeMessage("", msg, function(response) {
if (chrome.runtime.lastError) {
console.log("ERROR: " + chrome.runtime.lastError.message);
} else {
console.log("Messaging host sais: ", response);
}
});
The docs' section about Native Messaging is pretty detailed and a great source of information.