From ca44c0aba5dc356e5ef59c94102dbba3008097c8 Mon Sep 17 00:00:00 2001 From: HikeMap User Date: Wed, 31 Dec 2025 09:57:01 -0600 Subject: [PATCH] Fix illegal constructor error for notifications on mobile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Changed from new Notification() to registration.showNotification() - Mobile browsers require ServiceWorkerRegistration API for notifications - Added vibrate pattern and badge icon for better mobile experience This fixes the "Illegal constructor" error when enabling push notifications on Chrome for Android and other mobile browsers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- index.html | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index e90cff1..a62a3b7 100644 --- a/index.html +++ b/index.html @@ -5406,11 +5406,15 @@ updateNotificationUI(true); updateStatus('Push notifications enabled!', 'success'); - // Test notification - new Notification('HikeMap Notifications Active', { - body: 'You will receive alerts about new geocaches and trail updates', - icon: '/icon-192x192.png' - }); + // Test notification using service worker + if ('serviceWorker' in navigator && registration) { + registration.showNotification('HikeMap Notifications Active', { + body: 'You will receive alerts about new geocaches and trail updates', + icon: '/icon-192x192.png', + badge: '/icon-72x72.png', + vibrate: [200, 100, 200] + }); + } } } catch (error) { console.error('Failed to setup push notifications:', error);