Author Topic: How to launch the Settings app from your own app  (Read 4879 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How to launch the Settings app from your own app
« on: August 25, 2015, 07:46:34 PM »
Here's how to launch the Settings app from your own custom app (note this only works for iOS 8 and above):

In Swift:

Code: [Select]
if let url = NSURL(string: UIApplicationOpenSettingsURLString) {
   UIApplication.sharedApplication().openURL(url)
}

In Objective-C:

Code: [Select]
if(&UIApplicationOpenSettingsURLString != nil)
{
   NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
   [[UIApplication sharedApplication] openURL:url];
}

NOTE: This gets even better in iOS 9 because the Settings scene has a Back button to take you back to your app!

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8
« Last Edit: November 15, 2015, 10:21:08 AM by kjmcneish »