How can I leverage subscription.getKey() in servic

2019-06-08 19:56发布

问题:

I'm building a push notification service for my web users using Google Chrome Push Notification Service based on Service Workers.

Currently GCM don't allow push messages to contains payloads in order to overcome this gap my service-worker detects the push-notification event and pulls message from server, however the service worker have no means to identify itself to the server in order to fetch the correct message.

Is subscription.getKey('p256dh') the best approach to accomplish this? Any examples or code available?

回答1:

Firefox dev version now support push notification with encrypted payload. You can find live example here https://people.mozilla.org/~ewong2/push-notification-test/. And source code here . If you want use firefox push notifications download and install https://www.mozilla.org/en-US/firefox/developer/