queue-run icon indicating copy to clipboard operation
queue-run copied to clipboard

WebPush

Open assaf opened this issue 3 years ago • 0 comments

https://developer.mozilla.org/en-US/docs/Web/API/Push_API

Conceptually should work similarly to WebSocket where you send a notification to the current user or specific user:

await webPush.send(myMessage);
await webPush.to(userId).send(myMessage);

There needs to be an API endpoint to associate subscription with a user, this could look like:

import { webPush } from 'queue-run';

export default webPush.subscription;

The client has one endpoint (of their choosing) and it can POST to that endpoint with the serialized PushSubscription object.

And if we support the expiration time, the client can unsubscribe a user by setting the expiration time to 0.

assaf avatar Feb 03 '22 18:02 assaf