How to link directly to your app’s Settings section

Screen Shot 2015-09-24 at 09.37.14

iOS 8 introduced a new UIApplication method that lets us deeply link to our own app’s section in the iOS Settings app. Previously users had to open the Settings app and hunt for the relevant section, which isn’t always easy to find.

To make use of this handy function, add a Settings.bundle to your app (if you don’t already have one), then open the Settings app with the following method:

It looks a bit complicated because we’re using three methods in one. We could also write those out to make it a bit easier to understand:

In essence we call openURL on UIApplication, with a URL which is defined in an enum constant (UIApplicationOpenSettingsURLString). The latter needs to be converted into a URL via the NSURL method URLwithString. Call this method and iOS will transition to the correct section in the Settings app.

Xcode / Simulator Bug

Note that there is a bug in Xcode that makes the Settings section sometimes show up empty. You can trigger this bug if you deploy from Xcode to Simulator or a real device and then execute this code. You must reboot Simulator or your device for the correctly populated Settings section to show up again.

To prevent any panic attacks from happening, deploy the app from Xcode and stop it. Head back to the app and trigger your method to execute the code. Only then will the section show up as it should. In a real world scenario this isn’t an issue because users won’t ever start your app directly from Xcode.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.