Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748type ShowNotification = ( title: string, options?: NotificationOptions) => Promise<void>
let showNotification: ShowNotification | null = null
export const setNotificationInstance = (sn: ShowNotification) => { showNotification = sn}
export const notify: ShowNotification = async (title, options?) => { const showCustomNotification = async () => { if (!showNotification) { return } await showNotification(title, { icon: '/img/icons/apple-touch-icon.png', badge: '/img/badge.png', tag: 'binome', renotify: true, silent: true, ...options } as NotificationOptions) }
try { if (!('Notification' in window)) { return }
if (Notification.permission === 'granted') { showCustomNotification() return }
if (Notification.permission !== 'denied') { const permission = await Notification.requestPermission()
if (permission === 'granted') { showCustomNotification() } } } catch (error) { return }}