0

Suppose that case when the client app has re-registered with the gcm itself but the server is unaware of this and now the server is sending notification to that particular client what I want is the notification should not be sent with the old registration id. How can this be done?

nurulnabi
  • 459
  • 3
  • 11

1 Answers1

0

If your server sends a message to an invalid Registration token, it will probably receive a NotRegistered error response. You should handle this error accordingly by removing the corresponding token. As per the documentaion I linked above:

For all these cases, remove this registration token from the app server and stop using it to send messages.

AL.
  • 36,815
  • 10
  • 142
  • 281
  • Listen, If my server is sending message on old registration token but the gcm server has new one even then the gcm server will send the message replacing the old token with new one(not always, ultimately old one will stop working) but what I want is if gcm server finds that the registration id is old then gcm server just not send the message and returns with response indicating that. – nurulnabi Feb 28 '17 at 04:39
  • let me explain my problem may be you can understand better. user1 is currently logged in and then user2 comes and re-installs the app and logs in. In this scenario neither user1 nor the server knows that the registration token of user1 has changed at this point if server sends message to user1 with the old token of user1 it will be delivered to user2. – nurulnabi Feb 28 '17 at 04:45
  • I do kinda get what you're trying to explain so far. When the app is uninstalled, it is expected that the registration token is *refreshed*. With that, it's the developer's responsibility to make sure that their App server is notified and delete that corresponding registration token. When sending a push to a specific user, it is advised to have a client-side verification, to make sure that the message is only shown to the designated user. – AL. Feb 28 '17 at 06:25