This commit is contained in:
parent
551fe07d0e
commit
3cd8752fe1
1 changed files with 15 additions and 12 deletions
|
@ -1,20 +1,23 @@
|
|||
<script>
|
||||
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
addEventListener('load', function () {
|
||||
navigator.serviceWorker.register('../sw.ts');
|
||||
});
|
||||
onMount(() => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
addEventListener('load', function () {
|
||||
navigator.serviceWorker.register('../sw.ts');
|
||||
});
|
||||
|
||||
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||
console.log(`The service worker sent me a message: ${event.data}`);
|
||||
alert("You can use the app offline");
|
||||
});
|
||||
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||
console.log(`The service worker sent me a message: ${event.data}`);
|
||||
alert('You can use the app offline');
|
||||
});
|
||||
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
console.log("registered service worker")
|
||||
});
|
||||
}
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
console.log('registered service worker');
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
|
|
Loading…
Reference in a new issue