Created
September 30, 2020 03:44
-
-
Save oahehc/8b04c59601aba2326b1362eda03bbc36 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", (event) => { | |
| if (event.data) { | |
| try { | |
| data = JSON.parse(event.data.text()); | |
| event.waitUntil( | |
| self.registration.showNotification(data.title, { | |
| body: data.content, | |
| icon: "/icon-192.png", | |
| badge: "/badge-192.png", | |
| }) | |
| ); | |
| } catch (e) { | |
| console.error('push event data parse fail'); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment