Search code examples
google-chrome-extensiongoogle-chrome-appchrome-extension-manifest-v3chrome-native-messagingchrome-extension-manifest-v2

Chrome Native Messaging - Host App should be packed with extension?


I am new to Chrome Extension. I have a project to create a chrome extension that can help our web app to communicate with other team's desktop applications.

So I know I need to use native messaging, so I need to create a native host. But I am confused about where I should keep the native host? Can it be packed with the chrome extension? So when I publish the extension, the other team can install the extension, then they will have the native host?

Or I need to zip the native host app, and send it to the other team?

Also, the examples about native messaging I found so far are all for Chrome Manifest V2, is there any example for native messaging in Manifest V3? What should I put into host_permission for nativeMessaging? I put nativeMessaging in Manifest V3 and it gave me an error.


Solution

  • The host app is a separate download on a separate [public] server.

    1. The users will install the extension from the web store.
    2. The extension tries chrome.runtime.connectNative, and on failure it opens a page showing how to download the app from some external URL and how to install/register it.

    ManifestV3 doesn't change anything for nativeMessaging. There's nothing it needs in host_permissions: the term host here means site. To adapt the examples you'll only need to change a couple of fields as explained in the migration guide.