Multiple devices registered when app is deleted and reinstalled causing multiple push notifications

We have been finding that deleting and reinstalling an app (or updating an app version) has caused multiple devices to be added to a single user object. This then seems to have the effect of sending multiple pushes to that user as it is sending on to each registered device.
Currently we are registering our devices like this:

NSString * deviceTokenString = [backendless.messagingService deviceTokenAsString:deviceToken];
 
 @try {
 NSString * deviceRegistrationId = [backendless.messagingService registerDeviceToken:deviceTokenString];
 NSLog(@"device token: %@, device registration id: %@", deviceTokenString, deviceRegistrationId);
 }
 @catch (Fault * fault) {
 NSLog(@"device token: %@, FAULT = %@ <%@>", deviceTokenString, fault.message, fault.detail);
 }

We are then subscribing a specific device to a specific chat using channels:

-(void) subscribeToPushChannel: (NSString *) channel {
 if (!_isSubscribed) {
 [backendless.messagingService registerDevice:@[channel]];
 _isSubscribed = YES;
 }
}

Is there a way to have a new device overwrite an old device on the Backendless database or is there a way for a device to be registered with the same details when an app is re-downloaded?
Any help would be very appreciated,
Simon

created internal ticket BKNDLSS-13025 to investigate issue

Simon, I already have response you in another thread. iOS device don’t have unique deviceId, so when you reinstall your app, it is registered with another Id, so new registration record is created.

Hi Vyacheslav,

So there is no way to stop this double/triple stacking if a user deletes and reinstalls the app? Once an app is in production it would be almost impossible to manually delete new devices as it would be impossible to know if a user had deleted the app meaning we would have to go through the database checking every user.

Is there any reason why this happens when an app is reinstalled but not when an app is merely reloaded? If we stored the tokenString on the app keychain and then reused it to register the device would this stop multiple devices being registered?

Simon

Hi Simon,

Thank you for idea with keychain, we have implemented it, you could update the latest Backendless SDK via pod (3.0.35 release) or from ios-SDK github (ComLibiOS and backendless).

This fix allows to avoid the additional device registrations in the future, but if you already have the double device registrations (with the same Device Token), you need to remove it manually from your app dashboard (“Messaging -> <channel name> -> Devices” bookmark). You could use “Search” field for this. Sorry for the inconvenience.

Regards,
Slava

Devices are not longer being double or triple stacked, thanks for the fix

I’m having this same problem. Has it been solved also for android?

(I’m currently using backendless:3.0.25)

This could occur when a device is registered more than once with the backend. When an app is deleted, the backend does not know about it. As a result, it is recommended to unregister device first on the fresh app install to perform the cleanup from previous installations.