From fb4b37c3378a05f4591fa6d62b5891216d20fb5c Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 23 Mar 2026 17:46:23 -0600 Subject: [PATCH] Fix iOS having notification token revoked --- web/public/notifications-worker.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/web/public/notifications-worker.js b/web/public/notifications-worker.js index ba4e033ea..a264a1e4e 100644 --- a/web/public/notifications-worker.js +++ b/web/public/notifications-worker.js @@ -19,16 +19,20 @@ self.addEventListener("push", function (event) { break; } - // @ts-expect-error we know this exists - self.registration.showNotification(data.title, { - body: data.message, - icon: "/images/maskable-icon.png", - image: data.image, - badge: "/images/maskable-badge.png", - tag: data.id, - data: { id: data.id, link: data.direct_url }, - actions, - }); + // event.waitUntil is required on iOS Safari — without it, the browser + // may consider this a "silent push" and revoke the subscription after 3 occurrences. + event.waitUntil( + // @ts-expect-error we know this exists + self.registration.showNotification(data.title, { + body: data.message, + icon: "/images/maskable-icon.png", + image: data.image, + badge: "/images/maskable-badge.png", + tag: data.id, + data: { id: data.id, link: data.direct_url }, + actions, + }), // eslint-disable-line comma-dangle + ); } else { // pass // This push event has no data