Skip to content

Instantly share code, notes, and snippets.

@kypflug

kypflug/sw-10.js Secret

Created December 15, 2017 02:01
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 kypflug/154e8984cfc20d8820cecaa7536154a1 to your computer and use it in GitHub Desktop.
Save kypflug/154e8984cfc20d8820cecaa7536154a1 to your computer and use it in GitHub Desktop.
function registerPush(appPubkey) {
if (navigator.serviceWorker) {
navigator.serviceWorker.register('sw.js')
.then(function(reg) {
return reg.pushManager.getSubscription().then(function(subscription) {
if (subscription) {
return subscription;
}
return registration.pushManager.subscribe({
userVisibleOnly: true, applicationServerKey: appPubkey
});
});
})
}
}
@Silic0nS0ldier
Copy link

Line 10, registration is meant to be reg right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment