Skip to content

Push Notification for Multi User

There are two approaches you can follow to handle push notification in multi-user mode:

Unregister User for Push Notification During Logout and Re-Register During OnLoaded Event of Next User

  • User can unregister push notification as part of logout (skipReset = true). This may not succeed if there is no network connectivity when the logout occurs.
  • Let's assume that the user has successfully unregistered, any attempts to send a push notification to User1 while logged out would fail and the sending system would be responsible for proper handling/queuing of failed push messages.
  • Always try to register for push notifications during the OnLoaded event.
  • If the same user logs in after logout (and they unregistered for push during logout) but the device does not have network connectivity at login, the user would not be registered for push even if they come into coverage later. This is an edge case that could be handled in the app logic via OnFailure handling logic and a connectivity check callback.
  • If a new user signs in, the OnLoaded registration would automatically switch the push registration to the new user. Since user switch requires connectivity, the new push registration should always be successful.

Unregister User for Push Notification During Logout and Re-Register During OnUserSwitch Event

  • Ideally User1 logs out (skipReset = true) and also unregisters for push notification.
  • Alternatively, User1 can also logout (skipReset = true) and not unregister for push notification.
  • In this specific case (when User1 does not call an unregister during logout), any push notification for User1 will continue to be received on the device while User1 is logged out.
  • When User2 logs in, during OnUserSwitch, register for push notifications to switch the notifications to User2.
  • User2 can see any push notifications sent between logout (or before if not cleared by User1) and the time OnUserSwitch completes.

In the above approaches even if you do not unregister for push notification during logout and only do the re-registration of new user, that should suffice. Because, the re-registration implicitly unregisters the previous user for push notification.

In a shared device scenario, it has to be an application decision on the usage of either of the two scenarios and consequently understand the behaviors of each. Application developers have to make sure push notification is handled in one of the above mentioned ways.

Last update: July 30, 2021