24 lines
584 B
TypeScript
24 lines
584 B
TypeScript
declare const Notification: any
|
|
|
|
export const notify = (message: string) => {
|
|
try {
|
|
if (!('Notification' in window)) {
|
|
return
|
|
} else if (Notification.permission === 'granted') {
|
|
new Notification(message)
|
|
} else if (Notification.permission !== 'denied') {
|
|
Notification.requestPermission((permission: any) => {
|
|
if (!('permission' in Notification)) {
|
|
Notification.permission = permission
|
|
}
|
|
|
|
if (permission === 'granted') {
|
|
new Notification(message)
|
|
}
|
|
})
|
|
}
|
|
} catch (error) {
|
|
return
|
|
}
|
|
}
|