Changing the APNS deviceToken when reinstalling the application

Good day!

We use the func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) to get the deviceToken. But when reinstalling the application, we get a new token every time.

At the same time, the old tokens remain "alive" and when trying to send a message, they do not return "bad_device_token", the code 200 is returned.

{"StatusCode":200,"Reason":"","ApnsID":"fc9b2cff-a0aa-40fe-8d1e-3d1edec0eeb6","Timestamp":"0001-01-01T00:00:00Z"}

Why can this happen? This is important for us, because rows from the "device" table are deleted only when we receive "bad_device_token". Thus, the number of devices in the table is constantly growing.

Eventually the old tokens will begin to fail. It’s intentional the token changes upon reinstallation.

Changing the APNS deviceToken when reinstalling the application
 
 
Q