5

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?

asked Oct 22, 2012 at 22:48

2 Answers 2

5

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.

answered Oct 26, 2012 at 18:23
Sign up to request clarification or add additional context in comments.

7 Comments

It doesn't have to be jailbroken. You can download iExplorer and still change that.
Even with iExplorer, you can't access root filesystem unless the device is jailbroken. See the "How do I access the real root?" question at macroplant.com/faq.php?program=iExplorer+(Mac)
This is a good solution, but unfortunately it's somewhat incomplete, at least on iOS 6.1. On first install/run of a new app, the - application:didRegisterForRemoteNotificationsWithDeviceToken: callback doesn't get triggered until the user hits "Allow". On later runs, even with the dialog successfully reset using the method you describe, the callback happens immediately after calling registerForRemoteNotificationTypes:. :(
patr1ck: I haven't verified on iOS 6.1, but last I checked the callback always happens immediately after calling registerForRemoteNotificationTypes. The documentation doesn't say anything about waiting for the dialog.
In iOS7, this file is in this location: /private/var/mobile/Library/BackBoard/applicationState.plist
|
0

Provided your code paths for iOS 5 and iOS 6 aren't too different, the easiest option is probably to just test that specific behaviour on iOS 6 — the callbacks you get on iOS 5 should be similar enough for it not to be an issue.

Alternatively, change the app's bundle ID. Slightly tedious (in the past I've needed to restart Xcode for it to notice that change in bundle ID), and you'll need a wildcard provisioning profile handy.

answered Oct 26, 2012 at 19:56

1 Comment

What do you mean test it on iOS 6? I haven't verified, but I don't think any of the options I tried will work on iOS 6 any more than they do on iOS 5.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.