Created
April 30, 2020 16:21
-
-
Save novaknole/bea8fe853e8b90357fb8565a17a2a094 to your computer and use it in GitHub Desktop.
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
self.addEventListener('pushsubscriptionchange', function(event) { | |
event.waitUntil( | |
fetch('https://pushpad.xyz/pushsubscriptionchange', { | |
method: 'POST', | |
headers: { 'Content-Type': 'application/json' }, | |
body: JSON.stringify({ | |
old_endpoint: event.oldSubscription ? event.oldSubscription.endpoint : null, | |
new_endpoint: event.newSubscription ? event.newSubscription.endpoint : null, | |
new_p256dh: event.newSubscription ? event.newSubscription.toJSON().keys.p256dh : null, | |
new_auth: event.newSubscription ? event.newSubscription.toJSON().keys.auth : null | |
}) | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment