export function setNotif(title, body = '', icon = '', tag = '') { Notification.requestPermission(result => { if (result === 'granted') { navigator.serviceWorker.ready.then(reg => reg.showNotification(title, { body, icon, tag }) ) } }) } export function eraseAllNotif() { Notification.requestPermission(result => { if (result === 'granted') { navigator.serviceWorker.ready.then(reg => reg.getNotifications().then(n => n.forEach(x => x.close())) ) } }) } export function EraseNotifwithTag(tag) { Notification.requestPermission(function (result) { if (result === 'granted') { // Replace 'specific-tag' with the tag you want to target const specificTag = tag; // Check if service workers are available if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(function (registration) { registration.getNotifications().then(function (notifications) { notifications.forEach(function (notification) { if (notification.tag === specificTag) { notification.close(); } }); }); }); } } }); }