1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-07-06 19:14:42 +02:00

Web app: Show "notifications not supported" alert on HTTP

This commit is contained in:
Philipp Heckel 2022-06-12 16:38:33 -04:00
parent cf0f002bfa
commit feef15c485
4 changed files with 48 additions and 6 deletions
web/src/app

View file

@ -74,8 +74,22 @@ class Notifier {
}
supported() {
return this.browserSupported() && this.contextSupported();
}
browserSupported() {
return 'Notification' in window;
}
/**
* Returns true if this is a HTTPS site, or served over localhost. Otherwise the Notification API
* is not supported, see https://developer.mozilla.org/en-US/docs/Web/API/notification
*/
contextSupported() {
return location.protocol === 'https:'
|| location.hostname.match('^127.')
|| location.hostname === 'localhost';
}
}
const notifier = new Notifier();