From ce8473c1e75ff688fac9e559e3a0df0541671028 Mon Sep 17 00:00:00 2001 From: do0ori Date: Fri, 7 Feb 2025 15:09:41 +0900 Subject: [PATCH] fix: Show background notification on iOS Since iOS does not support merging notifications via the tag property, display a fallback notification to indicate that a timer is running in the background. For non-iOS devices, continue using periodic notification updates. --- src/service-worker.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/service-worker.ts b/src/service-worker.ts index b2f8d55..34fc407 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -98,7 +98,14 @@ self.addEventListener('message', (event) => { } let intervalId; - if (!isIOS) { + if (isIOS) { + self.registration.showNotification(timer.title, { + body: 'Timer is currently running in the background', + icon: '/visual-timer/logo500.png', + tag: timer.id, + silent: true, + }); + } else { // Enable periodic notification updates only for Android intervalId = setInterval(async () => { remainingTime -= 500;