Multiple user accounts combined with GCMIntentService
I am having a problem with multiple accounts of my own type.
I am using GCM (Google Cloud Messaging) to receive messages from our application server. Now, since you need to do your own implementation GCMIntentService extending GCMBaseIntentService
, you need to override onRegistered(Context context, String regId)
, the problem here is that I want to send the saved data to an account (authentication token) to our app server in this method. To let the app server know which device / registration ID belongs to a particular account in our own database.
How do I know for which account I just registered with GCM inside the method onRegistered()
? (I couldn't find any similar question = ()
source to share
You will need to do this manually. GCM doesn't care about user accounts. This only applies to the device itself. In your case, I will register the device with GCM once and then reuse the same registration ID for all of your users, which means that when sending a GCM notification, you will need to provide some credentials to know which user you are for. send that specific notification.
So in a nutshell: register your device with GCM once and then send the registration ID you get +, all custom user account IDs to your app server. When sending a notification, add the user ID to the notification message, and then use it to determine which user of the user account it is intended for.
source to share