Dickens A S
Dickens A S

Reputation: 4054

Chrome browser push notification with data?

The chrome browser pops up a balloon with data as shown below

enter image description here

But Mozilla says the PushEvent.data is still experimental

This is an experimental technology Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.
Note: This isn't yet supported on any browser.

Now how facebook detect 5 notifications?, Are they re-establishing a http connection to detect it? or is it really coming with the PushEvent.data

Upvotes: 2

Views: 406

Answers (1)

Kinlan
Kinlan

Reputation: 16597

It is not coming from PushEvent.data, that is not yet fully implemented in Chrome.

The current process is that when the push event is received by your Service Worker you need to make a new fetch request from inside your pushnotification JS handler to your server. This means that you have to handle all the logic yourself but you can do a number of things:

  1. Maintain some knowledge or state of the user on the server and then push that back to the user and just show the notification directly
  2. Maintain some knowledge on the client as well and sync the changes in your SW from your local data store and then update the notification based off that.

Upvotes: 2

Related Questions