0

I am fetching Id and token using InstanceId and store somewhere in my app. After reinstalling the app, I got new token and id. When I'm using old token and id for sending message through gcm, it shows success. But if I use only token for sending message, then it shows canonical. Can someone explain this in details?

example -> result :

1) "oldId:oldToken" -> success

2) "oldToken" -> success and canonical with new token

3) "newId:newToken" -> success

4) "newToken" -> success

I have issue in 1st example: Why is that not showing canonical and new token?

Check link: click here

abielita
  • 13,147
  • 2
  • 17
  • 59
ashish raval
  • 55
  • 1
  • 7

1 Answers1

0

Be noted that Canonical ID is returned in the response when you send a message from your server to google's gcm server. A canonical registration ID is the registration token of the last registration requested by the client app . This is the ID that the server should use when sending messages to the device.

From this thread:

When you receive a canonical registration ID in the response from Google, the message was accepted by the GCM server and the GCM server would attempt to deliver it to the device. Whether it is actually sent to the device depends on whether the device is available (i.e. connected to the internet). So if your server sends a GCM message to both the old ID and the new ID, the device will probably get two messages.

A canonical registration ID is defined to be the ID of the last registration requested by your application. This is the ID that the server should use when sending messages to the device. If later on you try to send a message using a different registration ID, GCM will process the request as usual, but it will include the canonical registration ID in the registration_id field of the response. Make sure to replace the registration ID stored in your server with this canonical ID.

Old registration IDs can remain active for a while. However Google tells you that you need to update your regid for a particular device/app combination by means of the canonical ID in the response to your sent message.

Check this related SO question:

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59