Check and ask for the notification permission if nothing yet set

This commit is contained in:
Hadi Nategh 2016-07-11 12:24:59 +02:00
parent 77c1d67240
commit 77cd21c46b

View File

@ -93,10 +93,16 @@ egw.extend('notification', egw.MODULE_WND_LOCAL, function(_app, _wnd)
/**
* Check Notification availability by browser
*
*
* @returns {Boolean} true if notification is supported and permitted otherwise false
*/
checkNotification: function () {
// Ask for permission if there's nothing decided yet
if (Notification && Notification.requestPermission && permission == 'default') {
Notification.requestPermission (function(_permission){
permission = _permission;
});
}
return (Notification && Notification.requestPermission && permission == 'granted');
}