I'm trying out the GCM push notification API. So far it works fine, but I'm not sure how to post additional data.
I followed the steps on this page: https://developers.google.com/web/fundamentals/getting-started/push-notifications/step-07
So I ended up writing a curl
request like this:
curl --header "Authorization: key=myKey" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[myRegistrationId], \"additionalData\": {\"user_id\":\"1\"}}"
And then my sw.js
(my service worker)
self.addEventListener('push', function(event) {
console.log('Push message', event);
var title = 'test a';
event.waitUntil(
self.registration.showNotification(title, {
body: 'The Message',
icon: '/assets/img/logo.png',
tag: 'my-tag'
}));
});
Is there a way to read out the additionalData
in this event? Or am I not supposed to do it like this?
Thanks for reading!