Created
March 6, 2017 22:24
-
-
Save gauntface/b33d0fbd024c0560c6c082fe7fd2ad12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.addEventListener('push', function(event) { | |
| let pushData = null; | |
| if (event.data) { | |
| pushData = event.data.text(); | |
| } | |
| // Send message to page | |
| const promiseChain = self.clients.matchAll({ | |
| includeUncontrolled: true | |
| }) | |
| .then(function(clients) { | |
| const sendMsgPromises = clients.map(function(client) { | |
| return client.postMessage(pushData); | |
| }); | |
| return Promise.all(sendMsgPromises); | |
| }); | |
| event.waitUntil(promiseChain); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment