HOWTO remove device tokens received by Apple APNS feedback

16,858

Solution 1

The timestamp is the crucial element here. The timestamp sent by Apple indicates the last time the push service attempted to deliver a message to the device and found the app to be uninstalled. If the device has re-registered with your service since then there is no need to delete it.

Therefore, every single time your app loads and sends the token to your service, you should log the time in your data store. When you run feedback you should check the time from Apple and compare it to the time you last received an update from the app on the device. If the time Apple sends is newer then the time you received an updated then you should delete (or disable) the device. If the time from Apple is earlier then you do not need to delete it because the user has reinstalled the device since Apple last tried to deliver.

Solution 2

All devices given by feedback are 'failed' and should be removed. No feedback means no devices should be removed. It's covered over on the Apple Documentation:

Apple APN Documentation

Share:
16,858
Mladen
Author by

Mladen

Updated on June 11, 2022

Comments

  • Mladen
    Mladen almost 2 years

    I am successfully fetching Apple APNS feedback data via PHP. The structure that I am getting (after some processing) looks something like this:

    timestamp

    device token

    My question is how to know which of the device tokens should I remove from my database and stop sending notifications to them.

    Regardz,

    Mladjo