-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
28 lines (25 loc) · 785 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
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/push_sw/jquery-2.1.4.min.js'
]);
})
);
console.log('Installed', event);
});
self.addEventListener('push', function(event) {
console.log('Push message', event);
var title = 'Push message';
event.waitUntil(
self.registration.showNotification(title, {
'body': 'Click to enter food zone.',
'icon': 'images/food_zone.jpg'
}));
});
self.addEventListener('notificationclick', function(event) {
console.log('Notification click: tag', event.notification.tag);
event.notification.close();
var url = 'https://prem5192.github.io/service_worker/index.html';
return clients.openWindow(url);
});