Each time the user uninstalls and reinstalls the application, a new token is returned. So, for this tag, multiple registrations are created, which leads to duplication of pushers delivered to the same device.
As I understand it, there is only one working device token at a time Apple Push Notification Service (also see here ), so you will not have a problem with multiple valid device tokens for a single iOS device, but you can have multiple Azure Notification Hub registrations for one device token. To avoid this, you should check if there is already a registration for a specific device token, and if so, reuse and cleaning:
ASP.NET WebAPI-Backend Example :
// POST api/register // This creates a registration id public async Task<string> Post(string handle = null) { // make sure there are no existing registrations for this push handle (used for iOS and Android) string newRegistrationId = null; if (handle != null) { var registrations = await hub.GetRegistrationsByChannelAsync(handle, 100); foreach (RegistrationDescription registration in registrations) { if (newRegistrationId == null) { newRegistrationId = registration.RegistrationId; } else { await hub.DeleteRegistrationAsync(registration); } } } if (newRegistrationId == null) newRegistrationId = await hub.CreateRegistrationIdAsync(); return newRegistrationId; }
With Google Cloud Messaging , it looks like you can have several working GCM registration identifiers, so you need to take care of this. GCM has something called Canonical IDs ":
If an application error causes multiple registrations for the same device, it can be difficult to reconcile the state and you can duplicate messages.
GCM provides a facility called "canonical registration identifiers" easily from these situations. A canonical registration identifier is defined to be the identifier of the last registration requested by your application. This is the identifier that the server should use when sending messages to the device.
If you later try to send a message using a different registration ID, GCM will process the request as usual, but it will include the canonical registration identifier in the response_ registration field. Be sure to replace the registration identifier stored in your server with this canonical identifier, because in the end the identifier you use will stop working.