Service Workers & Progressive Web Apps
What is the purpose of the 'notificationclick' event in PWAs?
self.addEventListener('notificationclick', event => {
event.notification.close();
event.waitUntil(
clients.matchAll({ type: 'window' })
.then(clientList => {
if (clientList.length > 0) {
return clientList[0].focus();
}
return clients.openWindow(event.notification.data.url);
})
);
});