mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-19 02:53:17 +02:00
Fix auth base64, fix iPhone things
This commit is contained in:
parent
ccb9da9333
commit
160c72997f
7 changed files with 48 additions and 11 deletions
web/src/app
|
@ -5,6 +5,9 @@ import logo from "../img/ntfy.png";
|
|||
|
||||
class Notifier {
|
||||
async notify(subscriptionId, notification, onClickFallback) {
|
||||
if (!this.supported()) {
|
||||
return;
|
||||
}
|
||||
const subscription = await subscriptionManager.get(subscriptionId);
|
||||
const shouldNotify = await this.shouldNotify(subscription, notification);
|
||||
if (!shouldNotify) {
|
||||
|
@ -38,10 +41,14 @@ class Notifier {
|
|||
}
|
||||
|
||||
granted() {
|
||||
return Notification.permission === 'granted';
|
||||
return this.supported() && Notification.permission === 'granted';
|
||||
}
|
||||
|
||||
maybeRequestPermission(cb) {
|
||||
if (!this.supported()) {
|
||||
cb(false);
|
||||
return;
|
||||
}
|
||||
if (!this.granted()) {
|
||||
Notification.requestPermission().then((permission) => {
|
||||
const granted = permission === 'granted';
|
||||
|
@ -61,6 +68,10 @@ class Notifier {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
supported() {
|
||||
return 'Notification' in window;
|
||||
}
|
||||
}
|
||||
|
||||
const notifier = new Notifier();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue