Add sw register
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Alessio Davoli 2023-07-19 16:15:05 +02:00
parent 603f991bb7
commit bef977be5c

View file

@ -1,7 +1,23 @@
<script>
import { pwaInfo } from 'virtual:pwa-info';
import { onMount } from 'svelte'
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
$: webManifestLink = pwaInfo ? pwaInfo.webManifest.linkTag : ''
onMount(async () => {
if (pwaInfo) {
const { registerSW } = await import('virtual:pwa-register')
registerSW({
immediate: true,
onRegistered(r) {
console.log(`SW Registered: ${r}`)
},
onRegisterError(error) {
console.log('SW registration error', error)
}
})
}
})
</script>
<slot></slot>