I need to open Settings programmatically from within my app. I searched across SO but everywhere people say that it's impossible. But today I saw that it's implemented in Facebook app. There's a button on an UIAlertView
and when you click it you open the Settings. So indeed this is possible to open Settings, I have witnessed this myself. But how to do that? Does anyone know how Facebook does that?

- 108,386
- 14
- 159
- 186

- 21,488
- 17
- 97
- 161
-
Note that Facebook Application is open source and completely available on github. – Sulthan May 23 '14 at 08:31
-
Facebook didn't show this alert, the OS did it. It happens in certain circumstances such as Airplane Mode being turned on or WiFi being turned off, and the OS offers for you to open Settings and change it. – Guy Kogus May 23 '14 at 08:32
-
9@Sulthanthe note that the Facebook Application is not open source. Only the SDK is. – MatterGoal May 13 '15 at 08:38
-
Check this: http://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app/37439140#37439140 – guyromb May 25 '16 at 13:48
-
Visit this answer for Swift 3: [http://stackoverflow.com/a/34024467/5391914](http://stackoverflow.com/a/34024467/5391914) – Hamed Feb 28 '17 at 11:50
15 Answers
On iOS 8 you can open Settings programmatically!
Here is the code:
- (void)openSettings
{
BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
}
If your app has its own settings bundle, the settings will be opened showing your app’s settings. If your app does not have a setting bundle, the main settings page will be shown.

- 3,814
- 5
- 34
- 56

- 1,631
- 2
- 11
- 13
-
-
3Does anyone know how to open just Settings app not individual settings page? Facebook opens Settings app without directing to individual settings page. – Pei Jan 29 '15 at 16:59
-
-
-
`- (void)openSettings { NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; if (url != nil) { [[UIApplication sharedApplication] openURL:url]; } else { NSLog(@"cannot open settings, url is nil!"); } }` – Lubos Ilcik Apr 16 '15 at 09:27
-
7Attention: If you don't have set your settings bundle this code still opens the App settings (with "Notifications" and "Use Cellular Data") and not the generic settings. – MatterGoal May 14 '15 at 14:53
-
1how can you remove the app settings, so that it opens the general settings? Its already there in ios8 when you install the app. – vatti May 31 '15 at 10:53
-
2Would you please tell me how to delete the app setting bundle at xcode ? I always goes to the app Settings instead of general settings – Jeff Bootsholz Jul 07 '15 at 10:27
-
@decodingpanda Hey, yes actually it works for phonegap, but only for iOS > 8. I had to create a plugin just for calling this feature. – MontDeska Sep 03 '15 at 21:10
-
@RajuGujarati - did you find any solution for this ? Please let me know. – Tejas K Feb 02 '16 at 05:30
-
-
Is it possible to make the app that called this code not shut down or is that unavoidable after the user changes settings like camera or photo access? – app-dev Jul 17 '19 at 16:05
You can't, there is no API call to do this.
Only system dialogs, dialogs from Apple Frameworks, can open the settings app. In iOS 5 there was a app url scheme to open the system dialog but Apple removed it later.
With the coming of iOS 8 you can open the settings dialog on your apps page.
if (&UIApplicationOpenSettingsURLString != NULL) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
else {
// Present some dialog telling the user to open the settings app.
}

- 69,092
- 8
- 134
- 166
-
5
-
3That is because they are working very close with Apple and Apple integrated there service in iOS. It does not mean that you can do it! They might even be allowed to call some private API to open the settings app. – rckoenes May 23 '14 at 08:14
-
-
it shows up when you open the app with internet connection off – Andrey Chernukha May 23 '14 at 08:18
-
3I'm pretty sure that's simply a normal part of the app, THAT HAPPENS TO LOOK LIKE the Settings page. You know? – Fattie May 23 '14 at 08:18
-
9Hey guys, on iOS 8 open Settings programmatically is possible, see my answer – Vito Ziv Sep 17 '14 at 07:10
-
2@VitoZiv that is true, but when this question was asked my answer was correct. – rckoenes Sep 17 '14 at 07:21
-
-
2@FelipeBaytelman Yes you are right but when I answered this question it was correct. – rckoenes Apr 08 '15 at 07:28
-
-
https://developer.apple.com/documentation/uikit/uiapplicationopensettingsurlstring, is a non nullable, so do we really need "&UIApplicationOpenSettingsURLString != NULL" check? – BangOperator Sep 11 '17 at 05:59
-
On iOS 8 you can open Settings programmatically!
Here is the list of currently known URLs in the Settings app:
- (void) openSettings
{
if (&UIApplicationOpenSettingsURLString != nil)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
else
NSLog(@"UIApplicationOpenSettingsURLString is not available in current iOS version");
}
- prefs:root=General&path=About
- prefs:root=General&path=ACCESSIBILITY
- prefs:root=AIRPLANE_MODE
- prefs:root=General&path=AUTOLOCK
- prefs:root=General&path=USAGE/CELLULAR_USAGE
- prefs:root=Brightness
- prefs:root=General&path=Bluetooth
- prefs:root=General&path=DATE_AND_TIME
- prefs:root=FACETIME
- prefs:root=General
- prefs:root=General&path=Keyboard
- prefs:root=CASTLE
- prefs:root=CASTLE&path=STORAGE_AND_BACKUP
- prefs:root=General&path=INTERNATIONAL
- prefs:root=LOCATION_SERVICES
- prefs:root=ACCOUNT_SETTINGS
- prefs:root=MUSIC
- prefs:root=MUSIC&path=EQ
- prefs:root=MUSIC&path=VolumeLimit
- prefs:root=General&path=Network
- prefs:root=NIKE_PLUS_IPOD
- prefs:root=NOTES
- prefs:root=NOTIFICATIONS_ID
- prefs:root=Phone
- prefs:root=Photos
- prefs:root=General&path=ManagedConfigurationList
- prefs:root=General&path=Reset
- prefs:root=Sounds&path=Ringtone
- prefs:root=Safari
- prefs:root=General&path=Assistant
- prefs:root=Sounds
- prefs:root=General&path=SOFTWARE_UPDATE_LINK
- prefs:root=STORE
- prefs:root=TWITTER
- prefs:root=General&path=USAGE
- prefs:root=VIDEO
- prefs:root=General&path=Network/VPN
- prefs:root=Wallpaper
- prefs:root=WIFI
- prefs:root=INTERNET_TETHERING

- 7,579
- 2
- 37
- 63

- 741
- 9
- 11
-
2Can you link to any official Apple source for this or was it discovered by probing around somehow? – Joey Carson Jul 08 '16 at 20:53
-
bluetooth is prefs:root=General&path=Bluetooth The bluetooth menu is not inside the general item anyways, it's a top level item – wyu Sep 02 '16 at 17:46
-
Since bluetooth is a top level item, I would guess the correct url would be prefs:root=BLUETOOTH – BCI Sep 22 '16 at 12:37
-
-
1looks like most of these no longer work in iOS 10 http://stackoverflow.com/questions/38064557/the-prefs-url-scheme-not-woring-in-ios-10-beta-1-2 – wyu Oct 26 '16 at 20:31
-
6Just replace prefs to App-Prefs for iOS 10. Above code works for iOS 8,9,10. – Stalin Pusparaj Feb 16 '17 at 10:57
-
1"App-Prefs:root=Privacy&path=Location" is specific to `Location Services`. – dichen Jun 23 '17 at 20:55
-
-
2
-
1It might be [rejected during app review](https://stackoverflow.com/a/51093121/419348). – AechoLiu Nov 27 '18 at 03:08
-
1**DO NOT USE** this answer. My app just got rejected for `app-prefs:root=privacy`. – Can Poyrazoğlu Dec 19 '18 at 19:13
Vito Ziv's answer in Swift.
func openSettings() {
UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!, completionHandler: nil)
}
-
how do we get to wifi settings for a user to reconnect wifi while in app? – JMStudios.jrichardson Apr 19 '16 at 17:50
-
1@JMStudios.jrichardson there's no way for that yet. Only app settings – alexey.metelkin May 09 '16 at 07:45
-
1openURL is now depreated in Swift3, anyone have an updated example for that? – Geoff Sep 18 '16 at 14:58
The alert in the Facebook app that this question refers to is a standard alert which iOS displays itself when you set UIRequiresPersistentWiFi to YES in your Info.plist files and the user launches your app without a network connection.
To summarize the discussion here:
- There is no URL you can use to get to the root level of the Settings app.
- You can send the user to your app's section of the Settings app using UIApplicationOpenSettingsURLString in iOS 8.
- Your app can display the same alert as Facebook, which does open the root level of the Settings app, by setting UIRequiresPersistentWiFi to YES.

- 8,310
- 3
- 49
- 52
-
>>> *your app's section of the Settings app* <<< What is the behavior when you do not provide a `settings.bundle` for your app? I am finding that when launched via Xcode this URL takes me to the top level Settings page. But when via TestFlight, it goes to my (empty) app settings child page. But I did not create a `settings.bundle`, and there is not one in my `.app` product... – pkamb Sep 21 '15 at 22:21
-
As far as doing the same thing facebook does this should be the right answer. `UIRequiresPersistentWiFi` is what I was looking for to display the alert. However, does anyone know if you can programmatically trigger it during runtime instead of using the info.plist? @Richard Venable do you if there is a method that you could call so you could actually make use of this when a specific button is clicked? – user3832583 Nov 26 '16 at 20:17
A memo about prefs:root=
and Prefs:root
.
Yes, our App was REJECTED by Apple due to prefs:root=
and App-Prefs:root
URL scheme today (2018-06-29)
. They are private API.
For Swift 4,
Only UIApplication.openSettingsURLString is public API to open Settings.

- 17,522
- 9
- 100
- 118
-
Aug. 14th 2018 - Our app just got rejected for using this as well. It had been in out codebase for 3 releases before they finally rejected us for it. – Cameron E Aug 14 '18 at 19:46
-
-
No. I use `UIApplication.openSettingsURLString` now, and ask my boss to modify UI spec for this issue. – AechoLiu Sep 14 '18 at 08:11
if (&UIApplicationOpenSettingsURLString != NULL)
in iOS 8+ is always TRUE. So you can edit like this
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
(with new openURL for iOS 10)

- 2,569
- 3
- 17
- 39
If you want open application settings you need write method with UIApplicationOpenSettingsURLString.
fileprivate func openSettings() {
UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!)
}
If you need will open one of many settings, you need use this function
fileprivate func openSettings() {
UIApplication.shared.open(URL(string:"App-Prefs:root=General")!)
}

- 51
- 1
- 1
-
Do not use "App-Prefs:root=General" in your apps. It apple will reject your app for using non-public url in your application. Mine got regected – Ravi Kumar May 16 '19 at 07:26
To open settings of our own application in iOS 8 and later
, use following code.
- (void) openSettings
{
if(&UIApplicationOpenSettingsURLString != nil)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
else
NSLog(@"UIApplicationOpenSettingsURLString is not available in current iOS version");
}
For reference and detailed description please follow
if (&UIApplicationOpenSettingsURLString != NULL) {
UIAlertView_Blocks *alertView = [[UIAlertView_Blocks alloc] initWithTitle:NSLocalizedString(@"Camera Access Denied", nil)
message:NSLocalizedString(@"You must allow camera access in Settings", nil)
delegate:nil
cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
otherButtonTitles:NSLocalizedString(@"Open Settings", nil), nil];
[alertView showWithDissmissBlock:^(NSInteger buttonIndex) {
if (alertView.cancelButtonIndex != buttonIndex) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
}];
}
else {
UIAlertView_Blocks *alertView = [[UIAlertView_Blocks alloc] initWithTitle:NSLocalizedString(@"Camera Access Denied", nil)
message:NSLocalizedString(@"You must allow camera access in Settings > Privacy > Camera", nil)
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil, nil];
[alertView showWithDissmissBlock:^(NSInteger buttonIndex) {
}];
}

- 553
- 5
- 19
Here is a Swift 3 example with UIAlertController and UIAlertAction.
func showSettingsPopup() {
let alertVC = UIAlertController(title: "Notifications disabled", message: "Please, turn on notifications if you want to receive a reminder messages.", preferredStyle: .alert)
let close = UIAlertAction(title: "Close", style: .destructive, handler: { (action) in
print("close action handler")
})
let openSettings = UIAlertAction(title: "Open settings", style: .default, handler: { (action) in
guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings are opened: \(success)")
})
}
})
alertVC.addAction(openSettings)
alertVC.addAction(close)
present(alertVC, animated: true, completion: nil)
}

- 545
- 1
- 6
- 9
In many of the answers given here I see the use of "App-Prefs:root" "prefs:root" we should not use these in our apps to open settings app. As per Apple this is a non-public url scheme and if we use it our app will get rejected.

- 313
- 2
- 13
if #available(iOS 10.0, *) {
if let url = URL(string: "App-Prefs:root=Privacy") {
UIApplication.shared.open(url, completionHandler: .none)
}
} else {
// Fallback on earlier versions
}
Opening Privacy settings in App

- 611
- 6
- 10
Instead of using prefs:
, just use App-Prefs:
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString: @"App-Prefs:root=WIFI"]]) {
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"App-Prefs:root=WIFI"]];
}
.
Everything is here: https://medium.com/@thanhvtrn/how-to-open-settings-wifi-in-swift-on-ios-10-1d94cf2c2e60

- 301
- 1
- 13
SWIFT 3
UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)

- 3,930
- 1
- 21
- 16
-
openURL is outdated in swift 3, you should use open(URL(string: UIApplicationOpenSettingsURLString)!, options: [:], completionHandler: { _ in }) – Damian Dudycz Jun 16 '17 at 07:16