I am trying to setup a demo for Web Push Notifications using Service Workers. In the service worker, sw.js, I have the following code.
var title = 'Yay a message.';
var body = 'We have received a push message.';
var icon = 'icon.png';
var tag = 'simple-push-demo-notification-tag';
console.log("Hello!");
self.addEventListener('push', function(event) {
event.waitUntil(
self.registration.showNotification(title, {
body: body,
icon: icon,
tag: tag
})
);
});
This works okay. I wish to receive data that I have sent with my push cURL
request like title
and more. Is there any way to get all that data here in this waitUntil
method?
Any help is highly appreciated.