-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
32 lines (28 loc) · 898 Bytes
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
self.addEventListener('push', function(event) {
var title = 'La Banque des Territoires';
var body = event.data.text();
var icon = 'https://www.banquedesterritoires.fr/sites/default/files/favicons/favicon-32x32.png';
var tag = 'news-notification-tag';
var actions = [
{ action: 'explore', title: "Voir l'actualité", icon: '' },
{ action: 'close', title: "Fermer", icon: '' },
];
event.waitUntil(
self.registration.showNotification(title, {
body: body,
icon: icon,
tag: tag,
actions: actions
})
);
});
self.addEventListener('notificationclick', (event) => {
switch (event.action) {
case 'close':
event.notification.close();
break;
default:
console.log(`Unknown action clicked: '${event.action}'`);
break;
}
});