Activate Chrome app from webpage?

I am creating a chrome batch application (this is necessary since I want to access chrome.socket). I have a website from which I would like to call my application (if it is installed or ask the user to install it) by clicking the link. Is it possible? Unable to find a simple way for this workflow.

+2
source share
2 answers

url_handlers may be the best way to achieve this.

You can also use the externally_connectable manifest property to declare that your site can connect to your application, then call chrome.runtime.sendMessage or chrome.runtime.connect from your web page and process it in the chrome.runtime.onMessage handler in the application .

Which one works best depends on your needs. url_handlers is an easier way, but it will constantly assign the URL of your link to your application, so you cannot use it for anything else if the application is installed. externally_connectable more complicated, but it allows much more complex bidirectional communication between your website and application.

You can even use a combination of the two approaches if you need to: launch the application using the url_handlers function, and then establish the communication channel to the website after the application starts and starts.

+3
source

Applications can now (with Chrome 31, I believe ) register for URL processing by adding url_handlers in their manifest and finding the URL causing the application to start in the chrome.app.runtime.onLaunched event. If the application does not start, your hosted website will be downloaded, it can present a built-in installation with chrome.webstore.install .

+2
source

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


All Articles