I'm showing notifications, issue is they show every time the page is loaded, so saving the tag to local storage, then if tag is in local storage don't show the notification, however it saves to the local storage, but doesn't stop showing the notification. code is below:
Notification.requestPermission().then(function(result) {
if (result === 'denied') {
console.log('Permission wasn\'t granted. Allow a retry.');
return;
}
if (result === 'default') {
console.log('The permission request was dismissed.');
return;
}
var note = new Notification("New title", {body:"example here", icon:"the icon", tag:"431",
})
window.localStorage.setItem('Notification' , note.tag);
job_posted.onclick = function(){
location.href = 'https://www.example.com/page.php?id=343';
}
});
if(localStorage.getItem("Notification")){
Notification.close();
};
Thanks for any help.