small changes

This commit is contained in:
Xeovalyte 2022-10-04 17:06:49 +02:00
parent 9b4d24ceed
commit 1562a4696d

View File

@ -43,24 +43,10 @@ onMounted(() => {
if (process.client) { if (process.client) {
if ('serviceWorker' in navigator && window.isSecureContext) { if ('serviceWorker' in navigator && window.isSecureContext) {
messaging.value = getMessaging() Device.getInfo().then(info => {
navigator.serviceWorker.register('/sw.js').catch(e => alert(e)); if (info.platform === 'web') registerSW()
onMessage(messaging.value, (payload) => {
console.log('Message received. ', payload);
const { show } = useWebNotification({
title: payload.notification.title,
body: payload.notification.body,
icon: '/ios/256.png',
dir: 'auto',
lang: 'en',
renotify: true,
tag: 'wrbapp',
})
show()
}); });
} }
} }
@ -167,6 +153,27 @@ const registerFCM = () => {
}); });
} }
const registerSW = () => {
messaging.value = getMessaging()
navigator.serviceWorker.register('/sw.js').catch(e => alert(e));
onMessage(messaging.value, (payload) => {
console.log('Message received. ', payload);
const { show } = useWebNotification({
title: payload.notification.title,
body: payload.notification.body,
icon: '/ios/256.png',
dir: 'auto',
lang: 'en',
renotify: true,
tag: 'wrbapp',
})
show()
});
}
const logDeviceInfo = async () => { const logDeviceInfo = async () => {
const info = await Device.getInfo(); const info = await Device.getInfo();