Created
March 18, 2019 19:39
-
-
Save Serginho/c793a24e8355ce98b20fc8d33fd283d7 to your computer and use it in GitHub Desktop.
request subscription browser
This file contains 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
navigator.serviceWorker.ready.then(serviceWorkerRegistration => { | |
const options = {userVisibleOnly: true, applicationServerKey: applicationServerKey}; | |
serviceWorkerRegistration.pushManager.subscribe(options).then(pushSubscription => { | |
navigator.serviceWorker.controller.postMessage({ | |
action: 'REQUEST_SUBSCRIPTION', | |
subscription: pushSubscription | |
}); | |
uploadSubscriptionToTheServer(pushSubscription, userId); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment