iosapple-push-notificationsdevicetokenjavapns

how to prevent APNS device token redundancy in database


I am using apns notification for my app, and for this i am storing the apns device token in my sql database.

The issue is that every time the user deletes or installs the app, it generates a new device token and this gets stored in the database, since the same user can have multiple devices, I cant update the token for that user and a new record gets created. this has let to many records for the same device and same user. it might lead to performance issue later.

Please help. How do I fix the issue storing multiple tokens for same user.


Solution

  • Sorry for replying late, we fixed the issue by running another job which used to delete APNS token stored in database other than the latest one.

    Our database stored APNS tokens for each user and each device. Depending upon these uniqueness. only latest tokens for each device is kept in database to prevent multiple notification on same device.

    another solution is to use upset (insert or update), if any device already has a token then update the same with new one or insert.

    I feel IOS should provide reliable API to handle this. The present Delete token API is not reliable.