Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created July 2, 2018 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/627c831577d02b1c2f49d65e67954f8c to your computer and use it in GitHub Desktop.
Save goofmint/627c831577d02b1c2f49d65e67954f8c to your computer and use it in GitHub Desktop.
self.addEventListener('install', () => {
console.log('ServiceWorker がインストールされました');
});
self.addEventListener('push', ev => {
// payloadの取得
const {title, msg, icon} = ev.data.json();
self.registration.showNotification(title, {
icon: icon,
body: msg
});
self.registration.pushManager.getSubscription().then(subscription => {
console.log(subscription);
}, err => console.log(err));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment