diff --git a/assets/js/services/notifications.js b/assets/js/services/notifications.js index 75376cf..bec9df9 100644 --- a/assets/js/services/notifications.js +++ b/assets/js/services/notifications.js @@ -1,6 +1,8 @@ class Notifications { constructor() { - Notification.requestPermission(); + if (this.notifications_available) { + Notification.requestPermission(); + } } notifyTurn(player) { @@ -11,10 +13,14 @@ class Notifications { } notify(options) { - if (!document.hasFocus()) { + if (this.notifications_available && !document.hasFocus()) { new Notification("Chess", options); } } + + get notifications_available() { + window.Notification != undefined; + } } export default Notifications;