Skip to content

Commit 0fa14c8

Browse files
fix: enable push notifications by mounting ServiceWorkerRegistration
## Problem Push notifications were not working when timer completed - only sound would play. ## Root Cause ServiceWorkerRegistration component existed but was never mounted in the app, causing: 1. Service Worker never registered → navigator.serviceWorker.ready hangs 2. Permission state not synced to Zustand store → always shows 'default' 3. Notification condition fails silently even if user granted permission ## Solution Mount ServiceWorkerRegistration component in page.tsx to: - Register Service Worker on app load - Sync notification permission from browser to Zustand store - Enable notifications to be displayed via Service Worker ## Changes - app/[locale]/page.tsx: Import and render ServiceWorkerRegistration ## Verification ✅ Service Worker registration logs confirmed in console ✅ Build and lint passing ✅ Timer completion flow tested ✅ Ready for manual notification testing in real browser ## Testing Notes Full notification testing requires manual browser testing (not headless): 1. Open in regular browser 2. Grant notification permission 3. Complete timer 4. Verify notification + sound both trigger
1 parent 7b57830 commit 0fa14c8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/[locale]/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { TimerControls } from '@/components/timer/TimerControls'
1414
import { TimeInput } from '@/components/timer/TimeInput'
1515
import { SettingsPanel } from '@/components/settings/SettingsPanel'
1616
import { LanguageToggle } from '@/components/LanguageToggle'
17+
import { ServiceWorkerRegistration } from '@/components/notifications/ServiceWorkerRegistration'
1718
import { NotificationTest } from '@/components/notifications/NotificationTest'
1819

1920
export default function Home() {
@@ -115,6 +116,9 @@ export default function Home() {
115116

116117
return (
117118
<main className="flex min-h-screen flex-col items-center justify-center gap-12 p-8">
119+
{/* Service Worker Registration - runs once on mount */}
120+
<ServiceWorkerRegistration />
121+
118122
<div className="mx-auto w-full max-w-2xl space-y-12">
119123
{/* Header with Language and Settings */}
120124
<div className="relative text-center">

0 commit comments

Comments
 (0)