1 | /** |
||
2 | * Service Worker |
||
3 | * |
||
4 | * Please, keep it inside root directory! |
||
5 | * |
||
6 | * @link https://github.com/web-push-libs/web-push-php |
||
7 | */ |
||
8 | self.addEventListener('push', function (event) { |
||
0 ignored issues
–
show
|
|||
9 | if (!(self.Notification && self.Notification.permission === 'granted')) { |
||
0 ignored issues
–
show
The variable
self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
10 | return; |
||
11 | } |
||
12 | |||
13 | const sendNotification = body => { |
||
14 | // you could refresh a notification badge here with postMessage API |
||
15 | const title = 'Bluz notification'; |
||
16 | |||
17 | return self.registration.showNotification(title, JSON.parse(body)); |
||
0 ignored issues
–
show
The variable
self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
18 | }; |
||
19 | |||
20 | if (event.data) { |
||
21 | const message = event.data.text(); |
||
22 | event.waitUntil(sendNotification(message)); |
||
23 | } |
||
24 | }); |
||
25 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.