I have on a website facebook style notification in top right corner. I show there up to 5 latest notifications. I do initial pulling with child_added
One solution would be to have your local client listen for the last 5 latest notifications via ref.limitToLast(5).on('child_added', ...)
and then only render them to the user if some timestamp field on each of those notifications is newer than your local timestamp on the machine.
When writing those notifications from other clients, you could include a timestamp field as specified via Firebase.ServerValue.TIMESTAMP
, which will use the server's notion of the Unix timestamp. Readers of that data could then compare that timestamp to their local clock to make the aforementioned determination.