PushManager.subscribe() needs applicatonServerKey option.
See original GitHub issuePlease check the following links: https://tools.ietf.org/html/draft-thomson-webpush-vapid-02#page-6 https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe
I believe option is necessary to send encrypted messages.
The server key is currently used for WebPusher.encode()
The comment says
The server key is an ephemeral ECDH key used only for this transaction
However, I believe this key is not only for this transaction but also for the subscribe method.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
PushManager.subscribe() - Web APIs | MDN
The subscribe() method of the PushManager interface subscribes to a push service. It returns a Promise that resolves to a PushSubscription ...
Read more >Subscribing a User - web.dev
First we need to check if the current browser actually supports push ... The applicationServerKey option passed into the subscribe() call is ...
Read more >Beginners guide to Web Push Notifications using Service ...
Push notifications are very common in the native mobile application platforms like Android & iOS. The are most effective ways to re-engage ...
Read more >builtins.PushManager.subscribe JavaScript and Node.js code ...
log('Service worker is registired'); const subscription = await register.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: ...
Read more >Changing application server key in push manager subscription
Get the subscription using reg.pushManager.getSubscription() and check whether current subscription uses the new application server key.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
to get object data from subscription you can use: JSON.parse(JSON.stringify(subscription))
Sorry, got pulled into a few things. You should be able to call subscription
.getKey('auth')
from the push subscription object returned byregistration.pushManager.subscribe()
. If it’s any help, you can look at what I do in the Web Push Data Test Page. I’ll also be honest, I’ve not really checked if I’m being smart about how I do things in pywebpush if you’re not sending data. Mostly because not sending data is a LOT easier. You just do a POST to the endpoint you’ve gotten. No worries about the weird headers, no encryption dance. Heck, you don’t even need to get the various keys from the subscription. All you need to do is pass the VAPID info (if you want, again, not needed) and aTTL
(Time To Live for the notification). I’ve got a write up that describes a lot of this (probably in WAY more detail than most folks want) That link drops you off into the “Send A Push Notification With No Data” bit.