Support Topics Documentation Slack YouTube Blog

We are receiving double notifications for push notifications for some of our users

Hello.

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.

Thank you.
Kevin Dawe
TeamLinkt.

Hello @jay-maharaj,

thank you for reporting this issue, we are looking into it.
Please, let us know your App ID.

Regards,
Stanislaw

The Application ID is 5396D848-49DA-BBA7-FFCE-3183CE0A0000.

Thank you. I have created an internal ticket for this issue (you can reference it by it’s internal ID BKNDLSS-22194).

We will inform you here once we have any news.

We apologize for this inconvenience.

Regards,
Stanislaw

Hi @jay-maharaj,

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.

Regards,
Mark

Hi Mark.

Yes, that makes sense if they did in fact change their algorithm. If that’s true, are others also having this problem?

  1. 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?

  2. 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?

Thanks.
Kevin.

Hi Kevin,

For (1), I believe it can be done using business logic in the beforeCreate event. It can be implemented with Java, JS or Codeless.

For (2) we’re running a few queries so we can identify all the channels with duplicate tokens.

Regards,
Mark

Hi Kevin,

From what date would you like us to gather the information about duplicates?

Regards,
Mark

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.

Thanks,
Allan

@allan we have removed duplicates. There were removed 19168 records. Please check if everything is ok now.

We are investigating what we can do to prevent duplicates

@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

Any update on preventing duplicates?

Hi Jay,

I recommend the following approach to avoid duplicates from getting created:

Create an event handler in business logic (Cloud Code) for the create event in the DeviceRegistration table:

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.

For more information about event handlers, please see the documentation:
https://backendless.com/docs/bl-js/bl_event_handlers.html

Regards,
Mark