fixes
This commit is contained in:
parent
aeb7ccae4f
commit
bc3bd362a2
@ -36,14 +36,31 @@ const userAllPersons = ref([])
|
||||
const calEvents = ref([])
|
||||
const news = ref(null)
|
||||
|
||||
const messaging = getMessaging()
|
||||
const messaging = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
auth.value = getAuth()
|
||||
|
||||
if (process.client) {
|
||||
if ('serviceWorker' in navigator && window.isSecureContext) {
|
||||
navigator.serviceWorker.register('/sw.js');
|
||||
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()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,22 +95,6 @@ onMounted(() => {
|
||||
})
|
||||
})
|
||||
|
||||
onMessage(messaging, (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 getPersons = async (persons) => {
|
||||
userPersons.value = [];
|
||||
|
||||
@ -152,9 +153,7 @@ const setupNotifications = () => {
|
||||
}
|
||||
|
||||
const registerFCM = () => {
|
||||
const messaging = getMessaging()
|
||||
|
||||
getToken(messaging, { vapidKey: 'BI7l3nyGV6wJcFh7wrwmQ42W7RSXl46bmhXZJmDd4P-0K_JFP0ClTqjO-rr5H5DXBbmVR4kXwxFpUlo_d6cUy4Q' }).then((currentToken) => {
|
||||
getToken(messaging.value, { vapidKey: 'BI7l3nyGV6wJcFh7wrwmQ42W7RSXl46bmhXZJmDd4P-0K_JFP0ClTqjO-rr5H5DXBbmVR4kXwxFpUlo_d6cUy4Q' }).then((currentToken) => {
|
||||
if (currentToken) {
|
||||
console.log(currentToken)
|
||||
} else {
|
||||
|
@ -15,6 +15,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
|
||||
const app = initializeApp(firebaseConfig);
|
||||
|
||||
try {
|
||||
const messaging = getMessaging(app);
|
||||
} catch {}
|
||||
|
||||
const analytics = getAnalytics(app);
|
||||
})
|
Loading…
Reference in New Issue
Block a user