Does PWA share web-push subscription with the browser?

Viewed 169

I am currently working on the web-push notifications for a project and got a bit confused by the matter. I couldn't find any info on the topic, so please consider the following scenario:

  1. User subscribes for web-push notifications on m.example.com
  2. And then adds the page to home screen, e.g. installs PWA

So the questions are:

  • Will the browser have the same ServiceWorkerRegistration and PushSubscription as the PWA?
  • Does the result change if the user first adds to home screen and then subscribe?
  • Will the browser have subscription if the user subscribes via PWA?
1 Answers

On Chrome, yes, they are treated as the same, it doesn't matter how the user opens the PWA (home screen vs URL in a browser tab), it's the same experience, and data is shared between. And conversely, the subscription is the same no matter where the user subscribed from.

Safari does treat the installed vs browser tab as a different context and data is not shared between the two. But as abraham mention in the comments, Safari doesn't support web push, so it's kind of a moot point.

Related