Does GCM delete the old registration identifier if the user installs the application again immediately after uninstallation?

I found out that GCM marks the registration identifier for deletion when it cannot send the next push notification.

But in my case, the following situation happened to my user.

Scenario :

1) My user has installed the application and his device is registered with GCM.

2) The same user uninstalled and immediately installed the application. The second time a new registration identifier is generated.

3) These two registration identifiers are stored in my database.

4) Now this particular user receives two push notifications.

Now I have the following questions:

Questions:

  • Will GCM delete the old registration ID after some time?
  • Please suggest me how to deal with this situation?
+5
source share
1 answer

From the official documentation:

How to turn off pending client deregistration

The client application may be automatically unregistered after it is deleted. However, this process does not occur immediately. What happens in this case:

  • The end user uninstalls the client application.
  • The application server sends a message to the GCM connection server.
  • The GCM Connection Server sends a message to the GCM client on the device.
  • The GCM client on the device receives a message and detects that the client application has been deleted; discovery details depend on the platform on which the client application is running.
  • The GCM client on the device informs about the GCM connection so that the client application is uninstalled.
  • The GCM Connection Server marks the registration token for deletion.
  • The application server sends a message to GCM.
  • GCM returns a NotRegistered application server error message.
  • The application server must remove the registration token.

Note that it may take some time for the registration token to be removed from the GCM. Therefore, it is possible that messages sent during step 7 above enter a valid message identifier as a response, although the message will not be delivered to the client application. In the end, the registration of the token will be deleted, and the server will receive a NotRegistered error, without any additional action from the application server.

However, apparently, it may happen that you still get a notification for the old registration identifier, as users state in other matters:

For this problem, there is a feature called "canonical identifiers":

Canonical identifiers

If an error in the client application causes multiple registrations for the same device, it can be difficult to reconcile the state and the client application can lead to duplicate messages.

Implementing canonical identifiers can help you recover these situations more easily. The canonical registration identifier is the registration token of the last registration requested by the client application. This is the identifier that the server should use when sending messages to the device.

If you try to send a message using the old registration token, GCM will process the request as usual, but it will include the canonical identifier in the registration_id field of the response. Be sure to replace the registration token stored on your server with this canonical identifier, as eventually the old registration token will stop working.

+5
source

All Articles