We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 421e24b commit 55f56d3Copy full SHA for 55f56d3
src/serviceWorker.js
@@ -0,0 +1,19 @@
1
+self.addEventListener('push', function (event) {
2
+ if (!(self.Notification && self.Notification.permission === 'granted')) {
3
+ return;
4
+ }
5
+
6
+ const sendNotification = body => {
7
+ // you could refresh a notification badge here with postMessage API
8
+ const title = "Web Push example";
9
10
+ return self.registration.showNotification(title, {
11
+ body,
12
+ });
13
+ };
14
15
+ if (event.data) {
16
+ const message = event.data.text();
17
+ event.waitUntil(sendNotification(message));
18
19
+});
0 commit comments