How we can Detect app delete/ uninstall from the iPhone/iPad.

Hello Folks,


We are developing an app in which we are sending and receiving the push messages to each devices based on user_id and device token_id.We want reduce overhead of such devices from the database which are not using our app in devices & for the same we want to get the app delete/unninstall state using some code n other stuff.We are wondering if Apple does provide us any such services by which we can get the state as well as the device token_id.If any one have any idea onto this then please assist us with your experience.


Regards,

Azad

Replies

The push message service has a feedback channel which reports error messages when the application has been removed or the device no longer accepts the push messages.


See: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Appendixes/BinaryProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH106-SW4


"The Apple Push Notification service includes a feedback service to give you information about failed remote notifications. When a remote notification cannot be delivered because the intended app does not exist on the device, the feedback service adds that device’s token to its list. Remote notifications that expire before being delivered are not considered a failed delivery and don’t impact the feedback service. By using this information to stop sending remote notifications that will fail to be delivered, you reduce unnecessary message overhead and improve overall system performance."


The link is to the documentation which specifies the details.

We cannot exactly know when the user has deleted the application. However, I came across a situation today to detect uninstallation of application which is both device and user specific (only in specific case it will be known).

The following scenario may help you where you need to delete the data based on user and device: If you are using rest API services and authentication for your App, make sure you do this to track it.
  1. Make sure you store all your user Data by using combination of user id and device identifier as primary key.

  2. Consider a bool value for each device identifier for each user.

  3. When user logins to the app, make a service call and set bool to true for that device identifier and user id on server.

  4. When user logouts of the app, make a service call and set bool to false for that device identifier and user id. Delete all the user specific data( from device and backend) while logging out(Depends on your business logic).

  5. Now, if the user logins again and uninstalls the app without logging out, the bool will be left true and all the corresponding user and device specific data will not be deleted.

  6. When user logins on a device, check for that bool value before updating it to true. If it is already true, it means that the same user has uninstalled this app on that particular device and installed it again on the same device.

Please note that this logic works only if there are service calls in your app and there is some authentication initially. Also, we can know this only if same user tries to login into same device. Uninstallation of application in other use cases can't be known with this logic.

Hoping that this kind of logic may help someone as we are using this logic now. I am a newbie..please guide if I am wrong.