diff --git a/public/js/manifest.json b/public/js/manifest.json index 7565124..da3aa9b 100644 --- a/public/js/manifest.json +++ b/public/js/manifest.json @@ -2,6 +2,9 @@ "name": "Quill", "short_name": "Quill", "description": "Quill is a simple app for posting to your website", + "background_color": "#428bca", + "display": "standalone", + "start_url": "/dashboard", "icons": [ { "src": "/images/quill-icon-57.png", diff --git a/public/js/register-sw.js b/public/js/register-sw.js new file mode 100644 index 0000000..edbe214 --- /dev/null +++ b/public/js/register-sw.js @@ -0,0 +1,7 @@ +(function registerSW() { + if ("serviceWorker" in navigator) { + navigator.serviceWorker.register("/js/sw.js").catch((e) => { + console.log("Registration fail: ", e); + }); + } +})(); diff --git a/public/js/sw.js b/public/js/sw.js new file mode 100644 index 0000000..f9d8702 --- /dev/null +++ b/public/js/sw.js @@ -0,0 +1,14 @@ +// NOTE: This currently doesn't cache anything +// We are just installing it so that chrome users can be +// prompted to install Quill via add to homescreen +self.addEventListener("install", installWorker); + +async function installWorker() { + await self.skipWaiting(); +} + +self.addEventListener("activate", activateServiceWorker); + +async function activateServiceWorker(event) { + event.waitUntil(clients.claim()); // make the current sw the active sw in all pages +} diff --git a/views/index.php b/views/index.php index b06f20d..02f45e2 100644 --- a/views/index.php +++ b/views/index.php @@ -32,4 +32,5 @@ +