https://github.com/a2nt/silverstripe-progressivewebapp
https://github.com/a2nt/silverstripe-progressivewebapp
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/a2nt/silverstripe-progressivewebapp
- Owner: a2nt
- License: bsd-3-clause
- Created: 2020-04-01T19:03:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T01:37:54.000Z (over 2 years ago)
- Last Synced: 2025-03-27T15:21:22.522Z (over 1 year ago)
- Language: JavaScript
- Size: 484 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SilverStripe Progressive Web App
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
```
```