I am implementing chrome push notification for my website users. Which I am able to do successfully via service worker. I am following these articles/tutorials
- https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web?hl=en
- http://www.html5rocks.com/en/tutorials/service-worker/introduction/
This works very well when I want to send notification NOW i.e. without scheduling for future.
My Problem:
I want to schedule this notification for later in the day may be recurring, which I can do via cron. But GCM does not send you payload as stated here https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web?hl=en and I quote.
A downside to the current implementation of the Push API in Chrome is that you can’t send any data with a push message. Nope, nothing. The reason for this is that in a future implementation, payload data will have to be encrypted on your server before it’s sent to a push messaging endpoint. This way the endpoint, whatever push provider it is, will not be able to easily view the content of the push message. This also protects against other vulnerabilities like poor validation of HTTPS certificates and man-in-the-middle attacks between your server and the push provider. However, this encryption isn’t supported yet, so in the meantime you’ll need to perform a fetch to get information needed to populate a notification.
Because of this I am not able to figure out for which scheduled notification I have received push event in browser. As there might be multiple notification sent to GCM.
I am fetching last record in notification tables i.e. I am always showing last record data. As I don't know for which notification I am receiving push event in chrome browser.
My Question:
Is there a workaround to schedule notifications and show correct ones to the client/browser? Is it even possible in native chrome push api?