Background script hosting app chrome

I've been serializing for a while, but can't find an answer, so I'll get right: Can I use background scripts in a Chrome host app? All I can find are extensions, but this is an app, not extensions. And besides; if so, can this background script update the appcache in the background without running it on the page?

Update: I still haven't found an answer to this question. I've read every word I can find on google regarding this, but all it says is "app". This usually refers to a packaged application, not a hosted application. Anyone have any further details?

+3


source to share


2 answers


Yes, you can. You may have seen Chrome running in the background - you closed the browser, but you see a little Chrome icon in the taskbar (or elsewhere) and there is a process. I cannot find any specific information on how to do this, but not at first glance on Google, but I suppose the search will be done. And you always have the option to contact Google, they answer.

As for your second question - yep .



Edit: But at least on PC and Mac they can be forcibly closed - link

Edit2: I found an example app containing documentation - link

+1


source


Yes and yes.

I recently threw something like this for a web game I'm working on.

You cannot use Background Scripts specifically, but you need to use the API of the man pages and your site must be HTTPS (no HTTP permission).

All the documentation for hosted apps seems to have been removed though (I think Google is trying to get everyone to switch to W3C Manifests and Service Workers).

But this works in hosted apps https://developer.chrome.com/extensions/background_pages



There is also a way to do it in JavaScript from a webpage, but I can't find any documentation either.

Just to show an example manifest for ya

{
"name": "Example Hosted App",
"description": "An example hosted app.",
"version": "0.1",
"app": {
  "browse_urls": [ "http://example.com/", "https://example.com/" ],
  "launch": {
     "container": "tab",
     "web_url": "https://example.com/"
},
  "urls": [ "*://example.com/", "*://*.example.com/" ]
},
"permissions": [
  "background"
],
"background": {
  "page": "https://example.com/background/"
},
"manifest_version": 2,
"offline_enabled": true,
"icons": { "512": "logo.png" }
}

      

And at https://example.com/background/ (enter your own url here), you have to install AppCache and even Service Worker. Background pages in Chrome are just full web pages, but you don't see them, and several APIs are missing, so Google doesn't seem to block AppCache, Worker Services, Local Storage, or IndexedDB.

+1


source







All Articles