Skip to content

Commit

Permalink
fix: Show background notification on iOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
do0ori committed Feb 7, 2025
1 parent b97a3b1 commit ce8473c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ce8473c

Please # to comment.