Open akrherz opened 2 years ago
Possible idea: (You'd need to implement comment and the else statement can be changed to whatever. I have it there as debug and can be easily be overridden and set to cookies to check this.)
let permission = Notification.permission;
if(permission === "granted") {
showNotification();
} else if(permission === "default"){
requestAndShowPermission();
} else {
console.warn('You don\'t have permissions enabled or set to asked! Missing PERMS')
}
function showNotification() {
if(document.visibilityState === "visible") {
return;
}
var title = "New Notification";
var icon = "https://weather.im/live/images/nws.png"
var body = "Message to be displayed";
var notification = new Notification(title, { body, icon });
notification.onclick = () => {
notification.close();
window.parent.focus();
}
}
function requestAndShowPermission() {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
showNotification();
}
});
}
Bump @akrherz
Sorry, I am generally not doing much development of the Live client.
That's fine. Just making sure an idea of desktop notifications was actually seen for whenever you do.
Requested addition of desktop notifications.