diff --git a/apps/frontend/public/service-worker.js b/apps/frontend/public/service-worker.js index 56a7d01..31797c0 100644 --- a/apps/frontend/public/service-worker.js +++ b/apps/frontend/public/service-worker.js @@ -114,6 +114,7 @@ self.addEventListener('notificationclick', (event) => { ]) } } + if (clients.openWindow) { console.log('open new window', urlToOpen) @@ -121,15 +122,15 @@ self.addEventListener('notificationclick', (event) => { if (!client) { console.log('new window not opened') for (const client of clientList) { - client.postMessage({ - type: 'notificationClick', - url: urlToOpen, - tag: event.notification.tag, - payload: event.notification.payload, - matchUrl: false, - msg: 'new window not opened', - }) - break + return client.navigate(urlToOpen) + // return client.postMessage({ + // type: 'notificationClick', + // url: urlToOpen, + // tag: event.notification.tag, + // payload: event.notification.payload, + // matchUrl: false, + // msg: 'new window not opened', + // }) } } }) @@ -137,15 +138,15 @@ self.addEventListener('notificationclick', (event) => { console.log('clients.openWindow not available') for (const client of clientList) { - client.postMessage({ - type: 'notificationClick', - url: urlToOpen, - tag: event.notification.tag, - payload: event.notification.payload, - matchUrl: false, - msg: 'clients.openWindow not available', - }) - break + return client.navigate(urlToOpen) + // return client.postMessage({ + // type: 'notificationClick', + // url: urlToOpen, + // tag: event.notification.tag, + // payload: event.notification.payload, + // matchUrl: false, + // msg: 'clients.openWindow not available', + // }) } } })