Periksa notifikasi izin izin atau tidak
function handlePermission() {
return navigator.permissions
.query({name:'notifications'})
.then(permissionQuery)
// .catch(permissionError);
}
function permissionQuery(result) {
console.debug({result});
var newPrompt;
if (result.state == 'granted') {
// console.log('granted');
} else if (result.state == 'prompt') {
newPrompt = Notification.requestPermission();
swal("Please Allow Notification..","", "error");
} else if (result.state == 'denied') {
swal("Please Allow Notification..","", "error");
}
result.onchange = () => console.debug({updatedPermission: result});
return newPrompt || result;
}
handlePermission();
faheem