4
votes

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
What is the expected outcome? - noogui
I suppose the expected outcome is to have the same subscriptions on both mobile website and WPA and subscriptions and registrations also. We're currently testing, might have some results later on. - t1gor
I don't have sources but I think on most Android devices it will be the same ServiceWorkerRegistration but on iOS PWAs run in a different context. (Although iOS doesn't support push) - abraham

1 Answers

2
votes

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.