♻️ (notification)
This commit is contained in:
@@ -9,22 +9,17 @@ export const setNotificationInstance = (sn: ShowNotification) => {
|
|||||||
showNotification = sn
|
showNotification = sn
|
||||||
}
|
}
|
||||||
|
|
||||||
export const notify: ShowNotification = async (
|
export const notify: ShowNotification = async (title, options?) => {
|
||||||
title: string,
|
const showCustomNotification = async () => {
|
||||||
options?: NotificationOptions
|
|
||||||
) => {
|
|
||||||
const showCustomNotification = (
|
|
||||||
title: string,
|
|
||||||
options?: NotificationOptions
|
|
||||||
) => {
|
|
||||||
if (!showNotification) {
|
if (!showNotification) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
showNotification(title, {
|
await showNotification(title, {
|
||||||
icon: '/img/icons/apple-touch-icon.png',
|
icon: '/img/icons/apple-touch-icon.png',
|
||||||
badge: '/img/badge.png',
|
badge: '/img/badge.png',
|
||||||
tag: 'binome',
|
tag: 'binome',
|
||||||
renotify: true,
|
renotify: true,
|
||||||
|
silent: true,
|
||||||
...options
|
...options
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -35,7 +30,7 @@ export const notify: ShowNotification = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Notification.permission === 'granted') {
|
if (Notification.permission === 'granted') {
|
||||||
showCustomNotification(title, options)
|
showCustomNotification()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +38,7 @@ export const notify: ShowNotification = async (
|
|||||||
const permission = await Notification.requestPermission()
|
const permission = await Notification.requestPermission()
|
||||||
|
|
||||||
if (permission === 'granted') {
|
if (permission === 'granted') {
|
||||||
showCustomNotification(title, options)
|
showCustomNotification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user