fix(push): use unique tag for push notifications
This commit is contained in:
1 parent
7151597888
commit
25d77d5132
2 files changed
+4
-4
No files matched your search
@@ -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)));
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user