Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS push notifications behavior when app is deleted and then reinstalled

Tags:

I've encountered an unusual scenario where a user is continuing to receive notifications when my app has been deleted and then reinstalled. The scenario is as follows:

  • user installs the app from the appstore
  • user logs onto our app and we register them for notifications
  • user deletes the app from their device
  • user reinstalls the app from the appstore
  • user receives a notification even though they have not started the app up yet, logged in, etc

My understanding of the APNs architecture was that once your app is deleted from your device, it is de-registered from APNs by the OS itself. A reinstall of the app would not re-enable notifications until you called "registerForRemoteNotificationTypes" -- so if a note was sent to the device using the old token, APNs would not deliver it since the above method has not been called.

Is that not accurate?

like image 629
Vik Avatar asked Feb 13 '13 16:02

Vik


People also ask

Do push notifications work when app is closed iOS?

Apple does not offer a way to handle a notification that arrives when your app is closed (i.e. when the user has fully quit the application or the OS had decided to kill it while it is in the background). If this happens, the only way to handle the notification is to wait until it is opened by the user.

Can you view old iOS push notifications you've dismissed?

Unfortunately, there is no way to view notifications once you've deleted them. If you delete, clear, or open one, it will no longer appear on your iPhone's lock screen, and there's no way to retrieve it.

How do you know my app is uninstalled from the device?

Open the Google Play app on your Android phone or tablet, and tap on the menu button (the three lines that show up in the upper left corner). When the menu is revealed, tap on "My apps & games." Next, tap on the "All" button, and that's it: you'll be able to check all your apps & games, both uninstalled, and installed.


2 Answers

The token remains the same. It's even the same for all applications on the device. It only changes when you change the OS version. However, that still doesn't explain the strange behavior you encountered.

I believe that only after Apple identifies that the application has been uninstalled from the device (which usually happens when you send a notification to the app on a specific device after the device uninstalled it) it un-registers the app. If no notifications were sent to the app on the device that uninstalled the app between the time of uninstall and the time of the new installation, Apple don't know the device uninstalled the app, and therefore it is still registered for APNS.

The behavior of the feedback service supports my theory - if you uninstall the app and call the feedback service, you won't get the device token of the device that uninstalled the app. Only after you try to send a notification to that device, Apple will detect the uninstall and return that device token in the feedback service.

One last thing I should add - if the uninstalled app is the last one on the device that was registered for push notifications, the APN service will never know that the app was uninstalled, and therefore it will still be registered for APN after being re-installed.

like image 80
Eran Avatar answered Sep 20 '22 14:09

Eran


When you delete the app, the OS doesn't "de-register" it from APNS. You have to send a notification to a device that has deleted the app in order to "de-register" it. This may take a few tries from APNS until it figures out the app has been deleted.

like image 37
GabCas Avatar answered Sep 19 '22 14:09

GabCas