diff --git a/local-notifications/src/web.ts b/local-notifications/src/web.ts index 6c9da2ec8..3dd8c2156 100644 --- a/local-notifications/src/web.ts +++ b/local-notifications/src/web.ts @@ -30,6 +30,10 @@ export class LocalNotificationsWeb } async schedule(options: ScheduleOptions): Promise { + if (!('Notification' in window)) { + throw this.unavailable('Notifications not supported in this browser.'); + } + for (const notification of options.notifications) { this.sendNotification(notification); } @@ -67,6 +71,10 @@ export class LocalNotificationsWeb } async requestPermissions(): Promise { + if (!('Notification' in window)) { + throw this.unavailable('Notifications not supported in this browser.'); + } + const display = this.transformNotificationPermission( await Notification.requestPermission(), ); @@ -75,6 +83,10 @@ export class LocalNotificationsWeb } async checkPermissions(): Promise { + if (!('Notification' in window)) { + throw this.unavailable('Notifications not supported in this browser.'); + } + const display = this.transformNotificationPermission( Notification.permission, );