Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset push notification permission setting in ios5

I am developing an app that uses push notifications, and testing on a device with iOS 5.1.1. I would like to test the scenario where the user is prompted about push notifications during the app's first run. The dialog appears the first time I call registerForRemoteNotificationTypes, but never appears again, even if the app is re-installed from scratch. How can I clear the setting so that the dialog will appear again?

The same question was posted before, but the answers do not work for iOS 5 or later, as noted in the comments there.

Apple's documentation says to uninstall the app and mess with the clock to make it look like the app was uninstalled for a day, but this does not work on iOS5.

Another answer suggested running General -> Reset -> Erase All Content And Settings - I tried this, but it froze my device and I ended up having to power-cycle it. In any case, this is a heavy-handed solution that is not practical for testing.

Another answer suggested removing your app's entry from /private/var/mobile/Library/RemoteNotification/Clients.plist, but this file does not exist on iOS5.

Is there a way to accomplish this on iOS5?

like image 992
Jeff W Avatar asked Oct 22 '12 22:10

Jeff W


1 Answers

I found a solution that works if your device is jailbroken:

  • Use an app like iFile to open the file /var/mobile/Library/SpringBoard/applicationstate.plist with a property list viewer
  • Find your app's bundle identifier and delete the key SBRemoteNotificationClient
  • Restart SpringBoard - either reboot the device, SSH to the device and run killall SpringBoard, or use the Respring app.

Next time you run your app, it will show the notification permission dialog once again.

I've tested this on iOS 5.1.1.

like image 117
Jeff W Avatar answered Sep 28 '22 05:09

Jeff W