[w3c/push-api] Allow event batching (Issue #403)

jakearchibald created an issue (w3c/push-api#403)

Right now, Safari fires `push` events sequentially, as in it fires the event, then waits for all the `event.waitUntil` calls to settle, before it fires the next one.

Assuming that events are generally processed like this:

1. Look at push payload
2. Show notification based on that payload

Or:

1. Look at push payload
2. Make network request for data
3. Show notification based on payload + response

In cases where the device has a queue of push messages, it seems advantageous to batch these into a single event. This would allow developers to make a single network request, rather than a series of network requests, and be smart about the notification displayed, e.g. "You have 7 new messages".

There's prior art here with [`getCoalescedEvents`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/getCoalescedEvents).

This would need to be opt-in as part of `pushManager.subscribe`, eg:

```js
await serviceWorkerRegistration.pushManager.subscribe({
  coalesce: true,
});
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/push-api/issues/403
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/push-api/issues/403@github.com>

Received on Wednesday, 6 August 2025 11:58:43 UTC