gauntface / web-push-book

Web Push Book

Home Page:https://web-push-book.gauntface.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Receiving a 2nd notification before the 1st one has been fired (and aggreggating both of them)

kael opened this issue · comments

commented

Trying to bypass the size limit of push messages, I'm sending several push notifications that get aggregated by the browser.

But sometimes, irregularly and randomly, the 2nd notification is received before the 1st one is fired.

Then calling registration.getNotifications when the 2nd notification is received returns an empty array, the 1st one hadn't been fired.

To circumvent that, on server-side I'm sending notifications using setTimeout, something like that:

notifications.map((notification, index) =>
    setTimeout(() => sendNotification(notification), 150+index*150)
)

On client-side, I'm trying to force sequential firing of notification using setTimeout, but unsuccessfully.

Is there a way to aggregate these notifications when they're received in a very short delay ? Or would it be a bug ?

This happens on Android Chrome 59, Beta and Dev, and on Chrome 59 (Linux).

This doesn't sound like a bug, there is no guarantee on the order of messages.

Why don't you just do a fetch() request to an API on your server when you receive a single push?