4

I'm about to test Push notifications in my app. Now it works fine but I also need to test the possibility of the user not accepting push when the system alert is shown. However after first testing the case where the user accepts.

I can delete the app, restart the device and whatnot but the settings seems to remain. When I delete the app it is removed from Notification Center, but right after installing the settings are just as they where before deletion.

I can understand Apples point here in not having this dialogue shown all the time, but seriously; if the user deletes the app and re-installs - thats a manual act and it would not seem like spam if the question got asked again. It did pre-iOS5 anyway.

So:

  • Does Notification Center cache these settings?
  • If so, for how long?
  • And most importantly: can I somehow force test this? (setting device date into the future?)
sebrock
  • 1,214
  • 2
  • 15
  • 32

2 Answers2

7

Resetting the Push Notifications Permissions Alert on iOS
The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

Jerred
  • 451
  • 4
  • 7
  • 1
    As of 2013-09-17, Apple has updated the instructions on how to do it. It's a slight but important tweak to the steps; I've verified on iOS 7.1. @Jerred - thanks for the original link! 1. Delete your app from the device. 2. Turn the device off completely and turn it back on. 3. Go to Settings > General > Date & Time and set the date ahead a day or more. 4. Turn the device off completely again and turn it back on. – John Jacecko May 27 '14 at 20:19
1

The implementation of how Notification Center stores preferences is private and undocumented, but Since iOS is based on Mac OSX, it probably stores preferences in the same way - as files named based on your applications Identifier in a system directory and NOT in the directory structure for your app. You can verify this by changing the identifier of your app (but not anything else), and checking for the previous preference settings. This is not caching, it's just their chosen implementation of persisting that data. It's highly unlikely that you can do anything to make it 'forget' a preference for a deleted app.

RyanR
  • 7,728
  • 1
  • 25
  • 39
  • Right, the one way to do this is to change the identifier. However, I can't really see a reason for Apple to choose this persistence. Deleting an app would suggest the user is not interested anymore, thus all preferences should be deleted. All in-app prefs are anyway, just not the OS ones, specifically notification center settings. – sebrock Feb 09 '12 at 09:48
  • I suspect it's not intentional, just a side effect of legacy code. File a bug report on it, they use that info to drive change. – RyanR Feb 11 '12 at 03:12