9

The Chrome developer docs refer to something called Native Messaging to communicate with other desktop applications directly from the Chrome extension or app.

How can I tell when a desktop app has such native messaging available and what kind of communication it can accept? Is there a way to get the application to expose what it will communicate about?

If I needed to talk to the original developers of that desktop app, is this even the most common terminology (native messaging) so they understand what I am referring to?

Does native messaging function the same on both Windows and Mac?

1 Answer 1

19

An extension can only communicate with a native desktop application if that application is registered as a "native messaging host". This means that there must be some manifest file at a pre-defined, platform-specific location that declares that the application has "native messaging" capabilities and which extensions are allowed to communicate with this native messaging host.

So, by default, it is extremely unlikely that any of your desktop apps support native messaging. This term is a specific to Chrome/Chromium, and might not be understood by developers who are not familiar with Chrome/Chromium. Though every competent developer should be able to get native messaging to work after reading the documentation of native messaging.

Currently, the only supported way of communicating with native applications is through the standard input and output pipes (stdin / stdout) via a simple yet strict protocol. If the desktop app has a command-line interface, then you can easily write a proxy application that serves as a native messaging host and interacts with the desktop application. It is essentially the bridge between your Chrome extension and some other application. This proxy application can be written in any language that supports stdin/stdout, and it does not require any cooperation from the original developers of the desktop app.

The native messaging protocol is the same across all platforms, but you have to take the endianness of the system into account, and the locations of the manifest file also platform-dependent.

17
  • 2
    TL;DR: if you didn't write the app yourself, you're probably not going to get it to work with Native Messaging.
    – sowbug
    Aug 7, 2014 at 20:52
  • 4
    I am a competent developer and I could not get native messaging to work from the documentation, as it is incomplete - no discussion of how to write, configure, install the native application, no mention of gotchas that are mentioned elsewhere on the web. I got it working, but I had to find multiple other sources, and not one single source, to put it all together.
    – DaveWalley
    Nov 6, 2014 at 23:08
  • @DaveWalley Could you highlight the issues you have with the documentation? I can try to get it fixed.
    – Rob W
    Nov 6, 2014 at 23:16
  • 2
    No discussion of how to write, configure, install the native application, no mention of gotchas that are mentioned elsewhere on the web including manifest name must be all lower-case, and console apps will not be visible. No discussion of error conditions and messages, how to see them and what they mean. No mention that you have to take the endianness of the system into account, and how you would handle endianness in code.
    – DaveWalley
    Nov 7, 2014 at 1:50
  • 3
    I know all of this from reading other people's work. I was responding to the statement "Though every competent developer should be able to get native messaging to work after reading the documentation". The documentation is not sufficient, you have to read other stuff, such as your comments on this page.
    – DaveWalley
    Nov 12, 2014 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.