From af3fe793db153c23262a2444b1f3c73baf9d9a8c Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Tue, 7 Apr 2026 23:08:51 +0200 Subject: [PATCH] [call-me] - #3 fix test push notification --- public/client.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/public/client.js b/public/client.js index 9c271c5..1720c1d 100755 --- a/public/client.js +++ b/public/client.js @@ -2225,8 +2225,19 @@ function updatePushTestBtn() { } // Handle test push notification button -function handlePushTest() { - sendMsg({ type: 'testPush' }); +async function handlePushTest() { + try { + const registration = await navigator.serviceWorker.ready; + await registration.showNotification('Call-me', { + body: 'Push notifications are working!', + icon: '/favicon/favicon-32x32.png', + badge: '/favicon/favicon-16x16.png', + data: { url: '/', type: 'testPush', caller: '' }, + }); + } catch (err) { + console.warn('Direct notification failed, falling back to push:', err); + sendMsg({ type: 'testPush' }); + } toast(t('push.testSent') || 'Test notification sent', 'info', 'top', 3000); }