Ionic PUSH and multiples users account users on the application

Hello,

Could you advices me about how to assign the user_id field for the PUSH / IonicUser registration.

My application can be used with OR without user identification.

So, if the user is not logged, I would like to receive general push notifications ( eg: new information to send to all users )

But I also need to push private notifications to some logged users. Imagine one device, a user log in, I need to show him his private push notifications (and after the app closed if he don’t logout)

But if the user logout, I need to stop to receive his private push notification ( and may be another user will log into the app on the same device )

So, may be I need to firstly registered the device with user_id = device.UUID and when a user login, update the push/ionicUser with the user_id of my new logged user ( eg: his unique email address )

But, what happends if the same user is logged at the same time on 2 devices ? Is it authorized ?

So, I’m confused on how to choose correctly the user_id, any help will be appreciated :slight_smile:

1- My application can be used with OR without user identification.

If you want to use push notification, the user_id is mandatory. $ionicUser.identify({user_id: <your_string_id>});

2- logged and anonymous users

One solution is using $ionicUser.generateGUID(); to generate an id for the user. Afterwards, you could set more attributes to your user, like $ionicUser.('email', <user_email>) or whatever you want to add to identify an logged user. Your solution (use the email as id) may work as well.

3 - what happends if the same user is logged at the same time on 2 devices ?

I really don’t know if it is possible to have a list of tokens.

1 Like

Ok thanks for your help @dionesandrade !

May be the best way is to only register the device.uuid, that’s all ( no push register/unregister on log in users )
But, when a user log in, I send to my server the device.uuid too, then in my server side, I known who is currently logged on which device.

Then, I could push users to the last device where they have been logged, or to every devices list.

This seems to resolve the problem.

1 Like