diff --git a/src/sw.ts b/src/sw.ts index 7a95dd8c..a58d60c8 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -145,7 +145,7 @@ const onPushNotification = async (event: PushEvent) => { self.navigator.setAppBadge(pushData.unread); if (pushData.unread == 0) { - self.registration.getNotifications({ tag: "Cinny" }) + self.registration.getNotifications() .then((notifications) => notifications .forEach((notification) => notification.close())); await navigator.clearAppBadge(); @@ -158,7 +158,7 @@ const onPushNotification = async (event: PushEvent) => { // Likely Firefox/Gecko-based and doesn't support badging API } - handlePushNotificationPushData(pushData); + await handlePushNotificationPushData(pushData); }; self.addEventListener('push', (event: PushEvent) => event.waitUntil(onPushNotification(event))); diff --git a/src/sw/pushNotification.ts b/src/sw/pushNotification.ts index cbcd21b2..f1331ff5 100644 --- a/src/sw/pushNotification.ts +++ b/src/sw/pushNotification.ts @@ -9,13 +9,13 @@ export const usePushNotifications = (self: ServiceWorkerGlobalScope) => { title: string, body: string, data: any, - silent: boolean = false + silent: boolean | null = null ) => { await self.registration.showNotification(title, { body, icon: DEFAULT_NOTIFICATION_ICON, badge: DEFAULT_NOTIFICATION_BADGE, - tag: "Cinny", + tag: data?.event_id ?? "Cinny", silent, data });