Definition
PushSubscription
A PushSubscription is the object returned by pushManager.subscribe(), containing an endpoint (a unique, vendor-hosted URL that identifies this specific device/browser installation) and a keys object with p256dh and auth values used to encrypt messages sent to it. Your server stores this per user and sends future notifications by POSTing an encrypted payload to subscription.endpoint.
A serialized subscription looks roughly like {"endpoint": "https://fcm.googleapis.com/fcm/send/abc123...", "keys": {"p256dh": "BN4G...", "auth": "tBHI..."}}, and this whole object — not just the endpoint — must be stored, since both keys are required to encrypt the payload correctly.
Subscriptions can expire or be revoked by the user (e.g. clearing site data, uninstalling the PWA, or the browser rotating the endpoint) — a 404 or 410 response from the push service when sending indicates the subscription is dead and should be deleted from your database.
pushSubscription.unsubscribe() lets the page programmatically end a subscription, which your app should call and sync to the server whenever the user turns off notifications in their settings, to avoid sending to a subscription nobody wants anymore.
Because the endpoint is vendor-specific (fcm.googleapis.com, updates.push.services.mozilla.com, etc.), your sending code needs a generic web-push library rather than hardcoding logic for one push service.