fixing notifications if service Worker is not registered

This commit is contained in:
Jonas Weinz 2019-03-31 15:55:54 +02:00 committed by GitHub
parent 4f9f0ed9a9
commit e262eb5b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -539,6 +539,12 @@ class WebsocketConnection
Notification.requestPermission(function(result) { Notification.requestPermission(function(result) {
if (result === 'granted') { if (result === 'granted') {
if (navigator.serviceWorker == undefined)
{
var notification = new Notification(text);
return;
}
navigator.serviceWorker.ready.then(function(registration) { navigator.serviceWorker.ready.then(function(registration) {
registration.showNotification(text, { registration.showNotification(text, {
icon: './icon.png', icon: './icon.png',