Push Notifications on Chrome - Is it possible to have multiple recipients on same browser?

2.8k Views Asked by At

Scenario -

  1. I log into account A on Chrome and enable push notifications for new messages. Works fine.

  2. I logout and login to account B on same browser. I want push notifications for account B when I am logged into account B.

Gmail does that when you manage multiple accounts from same browser. It shows push notifications for the currently logged in email account only.

To do such thing in my app, I have to unsubscribe from push notifications when I logout from account A and subscribe for push notifications again when I log into account B.

Is there a better way of tying that with current session?

Edit: I am thinking of registering a single client (i.e chrome browser on a machine) for multiple users and then send user ID with push notification payload to figure out whom to show the message.

1

There are 1 best solutions below

0
On

Implementing Push Messaging for Chrome does't require any gmail account if you are working for web. see: https://developers.google.com/web/updates/2015/03/push-notificatons-on-the-open-web?hl=en for more details and process to develop.

In this process it's register a service worker in browser so for a domain and browser, you can register a single service worker so it's not possible to subscribe multiple time for a same domain and same browser.