Hello i'm newbie and im hardly to understand this notification in service-worker, and because my knowledge isn't good yet then probably i will unable to explain my problem clearly.
so here's the code :
// triggered everytime, when a push notification is received.
self.addEventListener('push', function(event) {
console.info('Event: Push');
var title = 'New commit on Github Repo: RIL';
var body = {
'body': 'Click to see the latest commit',
'tag': 'pwa',
'icon': './images/48x48.png'
};
event.waitUntil(
self.registration.showNotification(title, body)
);
});
this is the code that trigger to POP the notification, what I do not understand is where the argument to accept/ receive the data ?
I've been searched a lot: https://auth0.com/blog/introduction-to-progressive-web-apps-push-notifications-part-3/ , https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web there's some new data JSON or from git-server or push api, but I still hardly to understand where's to accept the data.
sorry if you still do not understand what's my problem.
Here to make it simple what I want :
-
Let's say i make a button, and everytime i click the button it will value as 'True' and I want that 'True' value to pass into argument and trigger the push of notication in service-worker.
-
2nd questions: am I able to trigger notification with header or text in html ? since we can manipulate the text with DOM ?
-
am I able to trigger notification without GCM, or API cause I just want a simple notification in serivce-worker like above without passing much data.
-
If you give more advice or maybe notification without service-worker but real time , I am surely happy to read it but I hope Im able to understand.
via Dell Watson
No comments:
Post a Comment