some of our users are reporting receiving two push notifications at a time for the same message. When I look in the Device Registration in System Data, there are two records with the same device token for the same channelName.
This has just started in the last couple weeks. Prior to that it was working fine. We have not updated our app in quite some time so it doesn’t appear to be an issue that we’ve created.
For example, for channelName “user6wHiO4kBmEfAkSCRCHP9O6sv6Bw2” there are 2 records with the same device token. How could this be? For any device token there should only be one record.
I downloaded the entire DeviceRegistration list and there are dozens of others that have records with the same device token. Is there a way to clean this up to remove the duplicates?
If you need any additional information or screenshots, please let me know and I’ll will provide it to you.
We have researched this issue more in depth now. What we see in these duplicate device registrations is that all information is the same except deviceId. That is both channelName and token are the same, but the device ID is different. We obtain deviceId directly from iOS, it is used to uniquely identify the device to prevent this very situation you’re running into. What it appears is that Apple has changed the algorithm for generating deviceId. And now the same device is being identified differently.
Does it make sense?
Please let me know if we will need to work together to figure out (1) how to prevent the duplication and (2) how to clean up the duplicates.
Yes, that makes sense if they did in fact change their algorithm. If that’s true, are others also having this problem?
Is this something that can be handled on your side to make sure there isn’t a duplicate device token? If the channelName and token are the same but the device id is different, delete the old record and add the new one. Does that work?
Can you identify how many duplicates there are? We’ll need your help to clean them up. I would think that deleting the duplicate record with the oldest created date would do it.
Does that make sense to you? What are your thoughts on resolving this?
Hi Mark,
We need your help to delete duplicate records. Can you help to delete duplicate record (with older creation date)?
For future development, do you have any proposal? When we call registerDevice from iOS or Android device, do you query the DeviceRegistration table with the deviceId and channel name to check if the record exist. If the record does not exist, you will create one. If that’s case, can you make the query condition (channelName = <channel_name> && deviceId = <device_id>) || (channelName = <channel_name> && deviceToken = <device_token>). It should ensure no duplicate record for the same deviceId or device token (for the same channel). One record per device. Update the deviceId in database if it’s changed.
Or could the SDK allow client pass the deviceId to the deviceRegister API? We can do something on the client side to ensure the deviceId we pass to the API is not changeable.
@allan One thing that I do not exactly as you ask, I have ignored the date creation. So I just removed one of the duplicate with out determination by date
The event handler can be in JS, Java or in Codeless. the event handler implementation should check if there is another record with the same token and channel. That check can be done using the Backendless API which is available in business logic. If such device registration already exists, you can either update the existing record or just let it be, but it would be important to stop the API event processing using this technique.