declare const Notification: any let showNotification: | ((title: string, options?: NotificationOptions) => Promise) | null = null export const setNotificationInstance = ( sn: (title: string, options?: NotificationOptions) => Promise ) => { showNotification = sn } export const notify = (title: string, options?: NotificationOptions) => { const showCustomNotification = ( title: string, options?: NotificationOptions ) => { if (!showNotification) { return } showNotification(title, { icon: '/img/icons/apple-touch-icon.png', vibrate: [300, 100, 400], tag: 'pair-programming', ...options }) } try { if (!('Notification' in window)) { return } else if (Notification.permission === 'granted') { showCustomNotification(title, options) } else if (Notification.permission !== 'denied') { Notification.requestPermission((permission: any) => { if (!('permission' in Notification)) { Notification.permission = permission } if (permission === 'granted') { showCustomNotification(title, options) } }) } } catch (error) { return } }