Subscription handling with different users in same browser/device

Hello,

I have a question about subscription handling in wonderpush.

In our case we include wonderpush with a user-id in out web application.

We check if user is subsribed via wonderpush (via WonderPush.isSubscribedToNotifications()) and then we save this boolean value in our system.

Now the following use case:

User A logs in and subscribes to push notifications. With this our system sets values “push_subscription” to true. After this the user logs out.

User B logs in - and without any subscription the WonderPush.isSubscribedToNotifications() returns a true. But it was not this user who subscribet but this browser/device.

Is there a better way to handle this?

Thanks for some help!

Best regards,

Timo

Hi Timo,

The subscription is controlled on a per device basis as the push permission is bound to a particular device (and Android or iOS phone, or a given browser – browser user profile in fact). So any installation that ends up being used on this device by switching between userIds will hence have the same status, either subscribed or not.

When switching userIds the SDK creates/reuses a new installation associated with the given userId. Think of it like loading a new profile for WonderPush. The properties are not shared between two installations, but the device is. So every installation on this device will end-up being opt-in (but only one at a time, the “active” one).

I don’t think you should treat the subscription any differently in your system.
But if you really need to, you could use installation properties to store some kind of flag per installation.

Hope it’s clear.
Best,