From cd7f3b4a9373e5d9f7b3364597445e872cc98872 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Thu, 2 Jul 2020 13:31:33 +0200 Subject: [PATCH] :sparkles: (notification) add img to notification --- src/utils/notification.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/utils/notification.ts b/src/utils/notification.ts index 6563764..9a9c288 100644 --- a/src/utils/notification.ts +++ b/src/utils/notification.ts @@ -20,27 +20,32 @@ export const notify = ( title: string, options?: NotificationOptions | undefined ) => { - try { - console.log(showNotification) - + const showCustomNotification = ( + title: string, + options?: NotificationOptions | undefined + ) => { if (!showNotification) { return } + showNotification(title, { + icon: '/img/icons/apple-touch-icon.png', + ...options + }) + } + + try { if (!('Notification' in window)) { return } else if (Notification.permission === 'granted') { - showNotification(title, options) + showCustomNotification(title, options) } else if (Notification.permission !== 'denied') { Notification.requestPermission((permission: any) => { - if (!showNotification) { - return - } if (!('permission' in Notification)) { Notification.permission = permission } if (permission === 'granted') { - showNotification(title, options) + showCustomNotification(title, options) } }) }