fix(date): correction on date utils
This commit is contained in:
@@ -40,18 +40,32 @@ self.addEventListener('message', (event) => {
|
||||
if (event.data && event.data.type === 'SHOW_NOTIFICATION') {
|
||||
const { title, options } = event.data
|
||||
|
||||
// Préparer les options de notification
|
||||
const notificationOptions = {
|
||||
icon: '/icon-192x192.png',
|
||||
badge: '/icon-96x96.png',
|
||||
tag: 'lediscord-notification',
|
||||
requireInteraction: false,
|
||||
data: {
|
||||
link: options.link || options.data?.link || '/',
|
||||
notificationId: options.data?.notificationId || options.notificationId
|
||||
},
|
||||
body: options.body || options.message || '',
|
||||
...options
|
||||
}
|
||||
|
||||
// Retirer vibrate si présent (iOS ne le supporte pas)
|
||||
// Le client devrait déjà l'avoir retiré, mais on s'assure ici aussi
|
||||
if (notificationOptions.vibrate) {
|
||||
// Vérifier si on est sur iOS (approximatif via user agent du client)
|
||||
// Note: dans le SW on n'a pas accès direct à navigator.userAgent
|
||||
// mais on peut retirer vibrate de toute façon car iOS l'ignore
|
||||
delete notificationOptions.vibrate
|
||||
}
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(title, {
|
||||
icon: '/icon-192x192.png',
|
||||
badge: '/icon-96x96.png',
|
||||
tag: 'lediscord-notification',
|
||||
requireInteraction: false,
|
||||
vibrate: [200, 100, 200],
|
||||
data: {
|
||||
link: options.link || '/',
|
||||
notificationId: options.data?.notificationId
|
||||
},
|
||||
...options
|
||||
self.registration.showNotification(title, notificationOptions).catch(error => {
|
||||
console.error('Error showing notification in service worker:', error)
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -90,8 +104,15 @@ self.addEventListener('push', (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Retirer vibrate pour compatibilité iOS
|
||||
if (notificationData.vibrate) {
|
||||
delete notificationData.vibrate
|
||||
}
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(notificationData.title, notificationData)
|
||||
self.registration.showNotification(notificationData.title, notificationData).catch(error => {
|
||||
console.error('Error showing push notification:', error)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user