Launching the Chrome Packaged Web App from the website

I have a Chrome-packed web application (which is required to access the serial port), and I would like to be able to run it from my site (with some data) when I click on the / link on this website.

It would be even better if he found that the user is not running chrome or does not have a web application installed and can direct them to the right place ...

Are there any examples? It seems obvious what I want to do, but I'm really trying to find something ...

+6
source share
2 answers

To run the application, you can use url_handlers , the recently added new Chrome feature 31). You can pass data in a URL.

You can check if the application is installed and initiate the installation, if not, using the Chrome function of the built-in installation .

+7
source

Found the best solution to this problem.

In @Vincent Scheib's solution, you need to redirect the user to / some / url or open a new window (which may actually be blocked as a popup). All this is not so good from UX aproach.

My solution is to create an application and configure externally_connectable . You must pass the url domain of the website that will try to open the application. For instance:

 "externally_connectable": { "matches": ["*://developer.chrome.com/*"] } 

Then in your packaged application against the background of the script, you can do something like this:

 chrome.runtime.onMessageExternal.addListener(function(message) { if(message.launch){ //This parameter will be passed in sendMessage method below chrome.app.window.create("main.html"); } }); 

Finally, to open the application, you must send a message using your packaged application identifier. For instance:

 chrome.runtime.sendMessage("mdoedhlejmepngilmgoenbhmipoclckb", { launch: true }); 
+2
source

Source: https://habr.com/ru/post/953762/


All Articles