Skip to content Skip to sidebar Skip to footer

How To Launch A Chrome App From A Chrome Extension?

Typically an app is opened from chrome://apps/ or in the button Chrome apps, but how would from an external Chrome Extension? My extension: ->manifest.json ->background.js

Solution 1:

If you own both items you can just use messaging to open the app window when receiving a message from the extension. This does not have a permissions warning that will repel users like management. https://developer.chrome.com/extensions/messaging

First, add this to both manifests:

"externally_connectable": { "ids": [ "idoftheotheritem" ] }

Then, listen for messages in your app and create a app window:

chrome.runtime.onMessageExternal.addListener(function() {
  chrome.app.window.create("app.html");
}

Finally, send from the extension:

chrome.runtime.sendMessage("idoftheapp", { launch: true })

Solution 2:

It's in the docs: chrome.management.launchApp

chrome.management.launchApp("YourAppsId", function(){
  if(chrome.runtime.lastError) console.error(chrome.runtime.lastError);
  else console.log("App launched");
});

You will need the "management" permission for that.


Edit: see Daniel Herr's answer for a less invasive solution.


Post a Comment for "How To Launch A Chrome App From A Chrome Extension?"