Sends a single message from an extension to a native application.
This takes two mandatory parameters: the name of the native application and a JSON object which is the message to send it. The browser will launch the native application and deliver the message.
This is an asynchronous function that returns a Promise
. The first message sent by the native application is treated as a response to the sendNativeMessage()
call, and the promise will be fulfilled with this message as a parameter. Note that you can't use runtime.onMessage
to get responses from the application: you must use the callback function instead.
A new instance of the application is launched for call to runtime.sendNativeMessage()
. The browser will terminate the native application after getting a reply. To terminate a native application, the browser will close the pipe, give the process a few seconds to exit gracefully, and then kill it if it has not exited.
For more information, see Native messaging.