how to identify the right persistent data in a service worker?

107 views Asked by At

I have a service worker within chrome that display push notifications when a users friends come online. I am looking to use IndexedDB to hold the data about the users friends e.g. name and URL to friends profile page.

My problem is that one user has many friends and Chrome does not support extra data.

How can I tell what what friend has just come online within the service worker? I know I could do a fetch to find the latest login and guess that way, but would prefer to avoid unnecessary ajax calls and SQL queries.

1

There are 1 answers

0
Marco Castelluccio On

Only the server knows who has just come online, so unfortunately you will need to fetch that information from the server.

In a few releases Chrome will probably support push payloads, so in the future you could send the info with the notification itself.