Skip to content Skip to sidebar Skip to footer

Gcm: Send Notifications Only For The Current User Logged In Application

For the application that I am working I need to integrate Google Cloud Messaging. After playing a little with different examples, I was able to send and receive a notification on m

Solution 1:

Yes its true that you have one google registration ID for the app per device.

But you can always register and unregister users at your own Server that will actually send messages to GCM and GCM will send this to the registered devices.

Define some interfaces for your Server like registerOnServer and unRegisteronServer , send some unique value for each user on this interface.

So, in your case, when A use Log ins , regitration is done on GCM first and register the user on your Server with registerOnServer inteface and while the user is logged in send notifications pertaining to him to GCM to be send to the device.

When A logs out, unregister him using unRegisterServer and do not send any messages from your Server to GCM as A is unregistered.

So,now if B Logs in even with the same device , register him at your Server and send his messages.

This shall solve your problem!

Post a Comment for "Gcm: Send Notifications Only For The Current User Logged In Application"