mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
23 lines
602 B
JavaScript
23 lines
602 B
JavaScript
self.addEventListener('push', function (event) {
|
|
if (event.data) {
|
|
const data = event.data.json()
|
|
const options = {
|
|
body: data.body,
|
|
icon: data.icon || '/icon.png',
|
|
badge: '/badge.png',
|
|
vibrate: [100, 50, 100],
|
|
data: {
|
|
dateOfArrival: Date.now(),
|
|
primaryKey: '2',
|
|
},
|
|
}
|
|
event.waitUntil(self.registration.showNotification(data.title, options))
|
|
}
|
|
})
|
|
|
|
self.addEventListener('notificationclick', function (event) {
|
|
console.log('Notification click received.')
|
|
event.notification.close()
|
|
event.waitUntil(clients.openWindow('/'))
|
|
})
|