How can I open the Settings app when the user presses a button?

18,577

Solution 1

As per @bnduati's answer, in iOS 8 you can use the following code to open your app's settings in the settings app:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Old answer:

From iOS 5.1 through iOS 7, it was not possible to open the settings app from another application.

You might want to investigate this framework for providing in-app settings.

There are quite a few other questions that discuss this topic:

iPhone - how to put Settings bundle seen through System Settings App into your own App?

Launch iPhone setting screen from Application?

How to send a user to the main iPhone Settings screen from within your iPhone App

Solution 2

In iOS 8 and later you can send the user to your app's settings in the following way:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Solution 3

You can use this on iOS 5.0 and later:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

Solution 4

I don't know if this is possible or not, but one issue is that the user would then need to navigate back to your app. You can instead have your own preferences view that can write to the same file that the preferences app will use by using NSUserDefaults.

[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];

[[NSUserDefaults standardUserDefaults] stringForKey:key]

Solution 5

Swift Syntax:

UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
Share:
18,577
Christian Gossain
Author by

Christian Gossain

Updated on July 21, 2022

Comments

  • Christian Gossain
    Christian Gossain almost 2 years

    From what I understand by using code like this:

    NSURL* appUrl = [NSURL URLWithString: @"URL"];
    [[UIApplication sharedApplication] openURL:appUrl];
    

    I can open Map, YouTube, Safari, Mail, iTunes and the App Store, when a user say presses a button.

    But I was wondering is it possible to open the Settings app with this method.

    Basically, the first time the user opens my app I want a UIAlertView to pop up to let the user know that they can change a specific setting if they want, and either they press OK or they press settings to take them to the settings app.

    I know that Apple do that in some situations, but is it possible for developers to do that?