mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2025-03-29 01:27:28 +01:00
Close #158 commitb759884dce
Author: Made Baruna <made.setia@gmail.com> Date: Thu Jul 21 21:57:38 2022 +0700 Add update popup commit00f8b192af
Author: Made Baruna <made.setia@gmail.com> Date: Thu Jul 21 20:09:18 2022 +0700 Add service worker commit1cd1e40c77
Author: Made Baruna <made.setia@gmail.com> Date: Thu Jul 21 11:38:37 2022 +0700 Update firebase config commitedc036f62f
Author: Made Baruna <made.setia@gmail.com> Date: Wed Jul 20 23:33:38 2022 +0700 Separate build getter commite780ab18bf
Author: Made Baruna <made.setia@gmail.com> Date: Wed Jul 20 22:16:28 2022 +0700 Update readme commit7f0890acba
Author: Made Baruna <made.setia@gmail.com> Date: Wed Jul 20 22:07:25 2022 +0700 Fix createEnv commit1df04e369f
Author: Made Baruna <made.setia@gmail.com> Date: Wed Jul 20 22:03:12 2022 +0700 Migrate to svelte-kit
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js');
|
|
importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-messaging.js');
|
|
|
|
const firebaseConfig = {
|
|
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
|
|
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
|
|
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
|
|
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
|
|
appId: import.meta.env.VITE_FIREBASE_APP_ID,
|
|
};
|
|
|
|
firebase.initializeApp(firebaseConfig);
|
|
|
|
const messaging = firebase.messaging();
|
|
|
|
messaging.onBackgroundMessage((payload) => {
|
|
console.log('Received background message ', payload);
|
|
|
|
const { title, body, url } = payload.data;
|
|
|
|
const notificationTitle = title;
|
|
const notificationOptions = {
|
|
body,
|
|
icon: '/favicon.png',
|
|
data: {
|
|
url,
|
|
},
|
|
};
|
|
|
|
self.registration.showNotification(notificationTitle, notificationOptions);
|
|
});
|
|
|
|
self.addEventListener('notificationclick', function (event) {
|
|
event.notification.close();
|
|
|
|
if (clients.openWindow) {
|
|
clients.openWindow(event.notification.data.url);
|
|
}
|
|
});
|