Skip to content

Instantly share code, notes, and snippets.

@hscale
Forked from arikanmstf/service-worker.js
Created December 19, 2019 16:52
Show Gist options
  • Select an option

  • Save hscale/d148391a2b00d7328d88e258162933c7 to your computer and use it in GitHub Desktop.

Select an option

Save hscale/d148391a2b00d7328d88e258162933c7 to your computer and use it in GitHub Desktop.
Service Worker Example
self.addEventListener('push', function (event) {
if (event && event.data) {
const data = event.data.json();
event.waitUntil(self.registration.showNotification(data.title, {
body: data.body,
icon: data.icon || null
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment