4
votes

I have application which has successfully integrated apple push notifications, when user logs in to the application app registers with the push notification and token is saved on our back-end, when user sign out from the app, we remove the push notification tokens from our back-end. but if user uninstall app from the device WITHOUT SIGN-OUT from app, and then re-install,in that case we can still send push notifications to the device, since app is newly installed and not logged in any user we have to remove tokens from the backend. since iOS app does not have any API for uninstallation events how can I remove device token from back-end. I can use push notification feedback service to get uninstalled device tokens but how can I resolve the issue when user removes the application and then reinstall.

I tested this scenario with skype, it also have this issue. (install Skype > Log In > (now you can send app to Background and send some chats from any other device, you will get push notifications) > then Remove app from Device without Sign-Out from Skype > Re-Install Skype > now if we send skype chat we receives push notifications but skype app is newly installed and no one is logged in)

3
I think this question and answer hints at a possible approach? stackoverflow.com/questions/14858224/… - perhaps a silent 'heartbeat' notification that will trigger the deregistration on the apple side prior to reinstall?Petesh
The only workaround i can think of is: 1) periodically do handshaking with your backend server (e.g. 1 hour), and you update a timestamp in your database 2) if for a user who has no handshaking for X hours, you can remove the device token stored on your server 3) But if a user goes offline for a long time, the token will be removed. Thus there should be a way to resend the token to your server when the user goes online. (Detect the network is available, register a device token & save to your server)John the Traveler

3 Answers

1
votes

I guess the best thing you can do is to preventively unregister/remove the tokens, when the app is started without a logged in user. You should update the registration anyways each time the app is started, so register/unregister at each app start, depending on if a user is logged in or not. This way, if the user reinstalls the app and starts it the first time, it will be unregistered.

This is the best behaviour you can achieve, as it is the same for Twitter, Facebook, Skype, etc...

0
votes

I think you are not able to get an event or detect if a user has removed the app or not. What you can do is to send periodic notifications to a device (only setting the badge, without sending a notification) and remove the tokens for what you get a 401 status code. Then you know the app has been removed and you can delete the token.

enter image description here

-1
votes

Yeah! as you have quoted yourself it will continue to send notification unless your server has the info that someone has logged out. Obviously you won't get the info when your app was uninstalled and then reinstalled.

Workaround: If your app is reinstalled you can call an API to deregister since no user is logged in.