I have a requirement to launch a chrome application from a web page , click . I found the following resources:
Which suggests using externally_connectable and url_handlers , but doesn't seem to work. Can I launch the chrome app correctly using the button on the web page by clicking the Chrome x extension icon .
I am new to this field and any help from you experts will be greatly appreciated :)
PS
I tried the following command when I clicked a button on my webpage,
chrome.management.launchApp('app id');
This led to an error Uncaught TypeError: Cannot read property 'launchApp' of undefined.
Uncaught TypeError: Cannot read property 'launchApp' of undefined
I found how to achieve this, someone else is facing this problem.
on your web page, click a button , for example, enter the following code,
//data passed from web to chrome app chrome.runtime.sendMessage('your_chrome_app_id', { message: "version" }, function (reply) { if (reply) { if (reply.version) { //log the response received from the chrome application console.log(reply.version); } } } );
in your chrome manifest.json application, define the url externally_connectablelike this:
externally_connectable
{ "name": "App name", "description": "App Desc", "version": "1", ... "externally_connectable": { "matches": ["*://localhost:*/"] } }
In the background.js application, configure a listener that will be called when a message is sent from a web page as follows:
chrome.runtime.onMessageExternal.addListener( function(request, sender, sendResponse) { if (request) { if (request.message) { if (request.message == "version") { //my chrome application initial load screen is login.html window.open('login.html'); //if required can send a response back to the web site aswell. I have logged the reply on the web site sendResponse({version: '1.1.1'}); } } } return true; });
Hope this helps :)
Hasitha . . URL
localhost:3905/manager
, _
"externally_connectable": { "matches": ["*://localhost:*/*"] }
- URL-
"externally_connectable": { "matches": ["*://localhost*"] }
. ://localhost '
Source: https://habr.com/ru/post/1545809/More articles:How to find element inside ng-repeat in protractor - angularjsHow to get all the value from an array object using javascript? - javascriptCould not compile python script using buildozer - windowshow to use removeObjectsInArray in swift - swiftCannot use chrome.management API - javascriptMark generic parameter type as functional interface in Java 8 - javaLaunch Google Chrome app from url - google-chromehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1545812/ios-view-controller-containment-child-view-controller-passes-touches-to-parent-view-controller&usg=ALkJrhgK1MjqpnQC39bQWXYXg4cB7OBNqQHow can I run a Chrome Packaged app through javascript? - javascriptAndroid v4.4.3 + app release only? - androidAll Articles