silverstripe-progressivewebapp/README.md

29 lines
857 B
Markdown
Raw Normal View History

2018-06-24 15:51:50 +02:00
# SilverStripe Progressive Web App
Tools to add progressive web app functionality to your silverstripe website
2020-04-01 21:42:13 +02:00
And make it available offline
2018-06-24 15:51:50 +02:00
## Installation
```
2020-04-01 21:42:13 +02:00
composer require a2nt/silverstripe-progressivewebapp
2018-06-24 15:51:50 +02:00
```
## Usage
2018-07-04 12:36:46 +02:00
- Install the module, run dev/build and fill in the settings in the siteconfig
2020-04-02 01:41:49 +02:00
- Add js to register the service worker (example can be found at client/src/app.js)
2018-07-04 12:36:46 +02:00
```
2020-04-01 21:42:13 +02:00
if ('serviceWorker' in navigator) {
var baseHref = (document.getElementsByTagName('base')[0] || {}).href;
if(baseHref){
navigator.serviceWorker.register(baseHref + 'service-worker.js').then(function() {
console.log('Service Worker Registered');
});
}
}
2018-07-04 12:36:46 +02:00
```
- Add the following tags to the head of your website
```
2020-04-01 21:42:13 +02:00
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="{$BaseHref}manifest.json" />
2018-07-05 18:04:16 +02:00
```