Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Settings Bundle Empty on First Visit

I have an app written in Swift (iOS 8) that, on the first time it is opened, offers to take you to the settings in the main settings panel of iOS. It uses this code:

UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

This works fine, except that the settings panel is empty when you arrive. If you tap the Settings back button, then go right back into the settings for the app, all of the options appear.

I assume this is related to the same issue where nsuserdefaults don't appear to exist until the user actually visits the settings panel.

Anyway, does anyone have any idea how to get around this?

Notes:

1) This occurs only on the first launch of the app AFTER it is initially installed. Once the settings panel has been visited at least once, it works fine.

2) My app already checks for the existence of an initial default value; if missing, it initializes ALL settings, both for the current session, AND writes them to the settings bundle — I have verified that this part is working by flipping one of the defaults from true to false and noticing that it is false upon first view of the settings.

like image 515
Bill Read Avatar asked Dec 02 '25 09:12

Bill Read


1 Answers

After further research and a couple of hours of fiddling around, I no longer have the problem. I think it is one of two things, with #2 being the most likely IMO:

  1. Moved initialization from my model class to my AppDelegate. (Despite verifying the preferences were being initialized successfully by my model class; I like doing it from the AppDelegate anyway.)

  2. Made sure I forced the SETTINGS App to quit before installing the new app (using the swipe-up gesture).

Even after doing #1 I saw the behavior randomly, and I think this has to do with the Settings App itself. Another behavior I saw was the list of installed apps under SETTINGS actually repeated itself — this would go away if I force-quit it. So my guess is that I should have been force-quiting settings between installs.

like image 74
Bill Read Avatar answered Dec 05 '25 02:12

Bill Read



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!