Reputation: 143
I'm trying to create just a simple html link to open a Chrome app when clicking it. Lets use the following example:
I have installed the app found at https://chrome.google.com/webstore/detail/videostream-for-google-ch/cnciopoikihiagdjbjpnocolokfelagl
If I open the app from the Chrome menus, it will open the app in a new browser tab, displaying chrome-extension://cnciopoikihiagdjbjpnocolokfelagl/app.html as the URL in the address field.
So, naively I thought that I could just specify that URL to make it open if the link is clicked, i.e:
<a href="chrome-extension://cnciopoikihiagdjbjpnocolokfelagl/app.html">Link to the installed Chrome App</a>
But that does not work. How should I do to link correctly to the (installed) app?
Upvotes: 9
Views: 18112
Reputation: 29796
If you are the owner of the app I recommend using url_handlers
.
These need to be registered in your apps manifest.json
.
...
"url_handlers": {
"openApp": {
"matches": [
"https://www.yourVerifiedDomain.com/openApp"
],
"title": "Open App"
},
}
...
Then you could launch the app with a simple link anywhere on the web or in an extension.
<a href="https://www.yourVerifiedDomain.com/openApp">Open App</a>
If you are not the owner of the app you'll need the management permission as Xan already pointed out:
chrome.management.launchApp("<appId>");
Upvotes: 2
Reputation: 4027
I have an alternative solution. My use case is I've written a Chrome App, that I need customers to use once, and only once. I was trying to figure out a friendly way to preclude these steps:
blah, blah, blah.
Instead you can look up your custom Chrome App at the Google Chrome Web Store, and get the web store link.
Heres the link, using the Chrome App mentioned in the original question above.
https://chrome.google.com/webstore/detail/videostream-for-google-ch/cnciopoikihiagdjbjpnocolokfelagl
That's pretty handy if you've never seen the Chrome App before. For my situation, that's all I really need. Info offered here (1.5 years after original question answered) in case somebody else has a similar need. And here's the link to the Chrome App store:
https://chrome.google.com/webstore/category/apps
Upvotes: -1
Reputation: 77561
If you were in control of the app in question, you could use externally_connectable
property and listen for requests to launch your app.
But it seems like you don't control that app. Normal webpage code is unprivileged and cannot call chrome-extension://
URLs and the like.
You could potentially make a launcher extension. Using the management
API you can launch the app with
chrome.management.launchApp("cnciopoikihiagdjbjpnocolokfelagl");
and that can, again, be triggered via web-to-extension messaging using externally_connectable
. But that obviously requires that your users have two distinct Chrome add-ons installed, the app in question and your launcher shim.
Upvotes: 4