-
Notifications
You must be signed in to change notification settings - Fork 0
/
service-worker.js
74 lines (65 loc) · 2.02 KB
/
service-worker.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js');
const CACHE_NAME = "news-v7";
var base_url = "https://api.football-data.org/";
workbox.precaching.precacheAndRoute([
{ url: '/', revision: '1' },
{ url: '/index.html', revision: '1' },
{ url: '/nav.html', revision: '1' },
{ url: '/pages/next.html', revision: '1' },
{ url: '/pages/result.html', revision: '1' },
{ url: '/pages/information.html', revision: '1' },
{ url: '/css/materialize.min.css', revision: '1' },
{ url: '/js/materialize.min.js', revision: '1' },
{ url: '/js/nav.js', revision: '1' },
{ url: '/js/api.js', revision: '1' },
{ url: '/js/idb.js', revision: '1' },
{ url: '/js/db.js', revision: '1' },
{ url: '/icon.png', revision: '1' },
{ url: '/favicon.ico', revision: '1' },
{ url: '/manifest.json', revision: '1' },
{ url: '/favorit.html', revision: '1' },
]);
workbox.routing.registerRoute(
new RegExp('/pages/'),
workbox.strategies.staleWhileRevalidate()
);
workbox.routing.registerRoute(
new RegExp(base_url + "v2/competitions/2003/matches"),
workbox.strategies.staleWhileRevalidate()
);
workbox.routing.registerRoute(
new RegExp(base_url + "v2/competitions/2003/teams"),
workbox.strategies.staleWhileRevalidate()
);
workbox.routing.registerRoute(
new RegExp(base_url + "v2/teams/"),
workbox.strategies.staleWhileRevalidate()
);
workbox.routing.registerRoute(
new RegExp("https://fonts.googleapis.com/icon?family=Material+Icons"),
workbox.strategies.staleWhileRevalidate()
);
workbox.routing.registerRoute(
new RegExp('/'),
workbox.strategies.staleWhileRevalidate()
);
self.addEventListener('push', function(event) {
var body;
if (event.data) {
body = event.data.text();
} else {
body = 'Push message no payload';
}
var options = {
body: body,
icon: 'icon.png',
vibrate: [100, 50, 100],
data: {
dateOfArrival: Date.now(),
primaryKey: 1
}
};
event.waitUntil(
self.registration.showNotification('Push Notification', options)
);
});