small changes
This commit is contained in:
parent
9b4d24ceed
commit
1562a4696d
@ -43,24 +43,10 @@ onMounted(() => {
|
||||
|
||||
if (process.client) {
|
||||
if ('serviceWorker' in navigator && window.isSecureContext) {
|
||||
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()
|
||||
Device.getInfo().then(info => {
|
||||
if (info.platform === 'web') registerSW()
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 info = await Device.getInfo();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user