GCM: Send notifications only for the current user logged in application

后端 未结 1 1284
野趣味
野趣味 2020-12-18 03:45

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 notificati

相关标签:
1条回答
  • 2020-12-18 04:20

    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!

    0 讨论(0)
提交回复
热议问题