How to open the PWA app on click of notification in the background
Im interesting to but no succes at all: on service-worker i add:
self.addEventListener(‘notificationclick’, function(event) {
let url = ‘https://myapp.com/’;
event.waitUntil(
clients.matchAll({includeUncontrolled: true,type: ‘window’}).then( windowClients => {
// Check if there is already a window/tab open with the target URL
for (var i = 0; i < windowClients.length; i++) {
var client = windowClients[i];
// If so, just focus it.
if (client.url === url && ‘focus’ in client) {
return client.focus();
}
}
// If not, then open the target URL in a new window/tab.
if (clients.openWindow) {
return clients.openWindow(url);
}
})
);
});
when i click nothing happens, i hope someone help