(notification) add img to notification

This commit is contained in:
2020-07-02 13:31:33 +02:00
parent 7f78971377
commit cd7f3b4a93

View File

@@ -20,27 +20,32 @@ export const notify = (
title: string, title: string,
options?: NotificationOptions | undefined options?: NotificationOptions | undefined
) => { ) => {
try { const showCustomNotification = (
console.log(showNotification) title: string,
options?: NotificationOptions | undefined
) => {
if (!showNotification) { if (!showNotification) {
return return
} }
showNotification(title, {
icon: '/img/icons/apple-touch-icon.png',
...options
})
}
try {
if (!('Notification' in window)) { if (!('Notification' in window)) {
return return
} else if (Notification.permission === 'granted') { } else if (Notification.permission === 'granted') {
showNotification(title, options) showCustomNotification(title, options)
} else if (Notification.permission !== 'denied') { } else if (Notification.permission !== 'denied') {
Notification.requestPermission((permission: any) => { Notification.requestPermission((permission: any) => {
if (!showNotification) {
return
}
if (!('permission' in Notification)) { if (!('permission' in Notification)) {
Notification.permission = permission Notification.permission = permission
} }
if (permission === 'granted') { if (permission === 'granted') {
showNotification(title, options) showCustomNotification(title, options)
} }
}) })
} }