문제

I encountered a problem with having multiple accounts of my own custom type.
I use GCM (Google Cloud Messaging) to recieve messages from our application server. Now since you need to make your own implementation of GCMIntentService extending GCMBaseIntentService, you need to override onRegistered(Context context, String regId) , the problem here lies in that I want to send saved data on the account (an auth token) to our application server in that method. So that the application server knows which device/registration id belongs to a certain account in our own database.

How am I going to find out for which account I just registered to GCM with inside the onRegistered() method? (I couldn't find any similar question =( )

도움이 되었습니까?

해결책

You will have to do that manually. GCM doesn't care about user accounts. It only cares about the device itself. In your case I would register device with GCM once and then reuse the same registration ID for all your users, meaning that when sending GCM notification you will have to include some identification data to know for which user you are sending that particular notification.

So in a nutshell: register your device with GCM once and then send registration ID you receive + all custom user accounts IDs to your application server. When sending notification, add user ID into notification message and then use it to determine to which custom account user it is intended.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top