1

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.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Jagira
  • 1,368
  • 2
  • 14
  • 29
  • Why is unsubscribing and subscribing again so inconvenient? From the perspective of multiple users sharing a profile it is the right thing to do privacy-wise, don't you think? Your question lacks a bit of details. Are you building an app/extension and work with chrome.gcm API or is that a web page using web push API? – fgorski Aug 10 '15 at 16:34
  • I also do not see the point of inconvenience in subscribing and unsubscribing. Especially when using real push notifications to the browser such as WebPush or GCM. The thing is you register the endpoint (browser itself) as a receiver. So it is no longer in the userspace once registered. The registration on the serverside binds the userspace and enpoint together. If you do no longer wish they are bound (in your case on logout) just unregister the endpoint for the user. – Bas Goossen Sep 22 '16 at 10:35

1 Answers1

2

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.

Yogendra
  • 2,139
  • 3
  • 14
  • 27