We use Firebase Cloud Messaging to deliver push notifications.
I recently started to see that push notifications are delivered twice to the same device.
When I went deeper, I found out that in our backend one device was registered using 2 tones of lights. And they both work. Therefore, the device token provided by iOS should not be changed.
According to the GCM Documentation , this can happen due to an error in the client:
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 may end up with duplicate messages.
Implementing canonical identifiers can help you recover these situations more easily. The canonical registration identifier is the last registration registration token 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 ultimately the old registration token will stop working.
So, if we send a push notification to the old token, we should get a response using a pair of values registration_id.
FCM :
message_id, registration_id:
registration_id, ( ) . , , registration_ids, ( ).
registration_id . , , FCM , registration_id .
:
{
"multicast_id": 9087190295926530487,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [{
"message_id": "0:1498726709849471%10726fcd10726fcd"
}]
}
: , FCM ? ?