import { NotificationRequest } from '@ucap-webmessenger/native'; export class NotificationService { notificationPermission: NotificationPermission; constructor() { this.notificationPermission = this.isSupported() ? 'default' : 'denied'; } public isSupported(): boolean { return 'Notification' in window; } requestPermission(): void { const self = this; if ('Notification' in window) { Notification.requestPermission().then(result => { self.notificationPermission = result; }); } } notify(noti: NotificationRequest) { const notification = new Notification(noti.title, { body: noti.contents }); notification.onclick = e => { console.log('notification.onclick'); }; notification.onclose = e => { console.log('notification.onclose'); }; notification.onerror = e => { console.log('notification.onerror'); }; } }