Вы должны хранить статус уведомления в localstorage.Когда пользователь нажимает кнопку «Закрыть», вы должны написать в localalstorage, например: localStorage.setItem('notification-closed',true)
А при уведомлении о вызове проверьте флаг localstorage, например: localStorage.getItem('notification-closed')
, если оно истинно, больше не отображает уведомление.
function notifyMe() {
if(localStorage.getItem('notification-closed')) {
return;
}
if (!("Notification" in window)) {
alert("This browser does not support system notifications");
}
else if (Notification.permission === "granted") {
notify();
}
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
notify();
}
});
}
function notify() {
var notification = new Notification('This months topic is stranger danger', {
icon: 'assets/qr-codes/studentmeshCourseVideo.png',
body: "this months topic is stranger danger click on me to a video that studentmesh has provided to educate your child about stranger danger or scan the qr code in shazam to get to the video",
});
notification.onclick = function () {
window.open("assets/course-videos/strangerDanger.mp4");
};
}
}