Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification Center caching settings?

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?)
like image 962
sebrock Avatar asked Feb 21 '23 22:02

sebrock


2 Answers

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.

like image 50
Jerred Avatar answered Mar 03 '23 21:03

Jerred


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.

like image 28
RyanR Avatar answered Mar 03 '23 22:03

RyanR