1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Check browser has notification capability

This commit is contained in:
Daniel Barber 2018-08-14 14:14:08 -04:00
parent 175bb9e5c7
commit 88416fcd54
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -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;