admin管理员组文章数量:1291135
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
My app:
->manifest.json
->background.js
Then, how to launch my app from my 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
My app:
->manifest.json
->background.js
Then, how to launch my app from my extension?
Share Improve this question edited Jun 13, 2014 at 6:59 Xan 77.6k18 gold badges197 silver badges217 bronze badges asked Jun 13, 2014 at 5:30 Walter Chapilliquen - wZVanGWalter Chapilliquen - wZVanG 12k8 gold badges44 silver badges64 bronze badges2 Answers
Reset to default 8If 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./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 })
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.
本文标签: javascriptHow to launch a Chrome App from a Chrome ExtensionStack Overflow
版权声明:本文标题:javascript - How to launch a Chrome App from a Chrome Extension? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741502230a2382113.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论