a2nt / silverstripe-progressivewebapp
Tools to add offline caching and the other progressive web app functionality to your silverstripe website
Installs: 606
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Language:JavaScript
Type:silverstripe-vendormodule
Requires
- silverstripe/cms: ^4.0@dev
- silverstripe/vendor-plugin: ^1.0
- silverware/colorpicker: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.0
README
Tools to add progressive web app functionality to your silverstripe website And make it available offline
Installation
composer require a2nt/silverstripe-progressivewebapp
Usage
- Install the module, run dev/build and fill in the settings in the siteconfig
- Add js to register the service worker (example can be found at client/src/app.js)
if ('serviceWorker' in navigator) {
var baseHref = (document.getElementsByTagName('base')[0] || {}).href;
var version = (document.querySelector('meta[name="swversion"]') || {})
.content;
if (baseHref) {
navigator.serviceWorker
.register(baseHref + 'sw.js?v=' + version)
.then(() => {
console.log('SW: Registered');
});
}
}
- Add the following tags to the head of your website
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="{$BaseHref}manifest.json" />
<meta name="swversion" content="{$SWVersion}" />