Storing/managing PWA push notification subscription data for same user with multiple devices?

Viewed 101

Maybe I'm misunderstanding something but every article/tutorial I've read about push notifications seems to be leaving this detail out.

For reference, web-push's sendNotification method accepts pushSubscription, payload, and options.

To send a notification to a user at any point in time, the user's pushSubscription data would need to be stored in a database and retrieved to be used as needed, right? So if the user has enabled push notifications for multiple devices, the pushSubscription data would need to be stored for each device.

I guess my question is... How do you know when e.g. a device is no longer in use so that you can delete the stale pushSubscription data? Or suppose, for whatever reason, the PushManager generates a new pushSubscription for the same user + device... How would you know to replace the old pushSubscription with the new one?

Is the solution to build a device manager for the user to manage each device and its associated push subscription(s)?

0 Answers
Related