46

At one point in my app, I would like to redirect the user to the official Settings app. If possible, I also want go straight to the Network section within the Settings app.

I think what I need is the Settings app's url scheme and the format to construct my request. But I doubt that calling such an official app is forbidden.

Can anyone can help me?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Di Wu
  • 6,436
  • 3
  • 35
  • 51

9 Answers9

44

As noted in the comments below, this is no longer possible in iOS version 5.1 and after.

If you are on iOS 5.0, the following applies:

This is now possible in iOS 5 using the 'prefs:' url scheme. It works from a web page or from an app.

example urls:

prefs:root=General
prefs:root=General&path=Network

sample usage:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]]
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]
mattorb
  • 3,075
  • 3
  • 22
  • 16
  • 6
    dude, you are awesome! after some poking around i found this one for twitter settings: `prefs:root=TWITTER` – jasongregori Nov 11 '11 at 03:54
  • 1
    Any idea if these calls are classified as 'undocumented'? I couldn't find them in the docs. How did you find them? Cheers, – MattyG Nov 14 '11 at 22:07
  • Is there a way to get into an App's settings menu?, EG prefs:root=Facebook – Jonathan. Nov 16 '11 at 16:52
  • 12
    @MattyG yes, definitely. in fact, i just read this article that said these no longer work in iOS 5.1: http://www.macstories.net/news/ios-5-1-beta-blocks-shortcuts-to-system-settings/ – jasongregori Dec 05 '11 at 21:37
  • 10
    Just a kind warning, http://www.idownloadblog.com/2011/11/29/iphone-5-1-disables-shortcuts/ said that all url schemes to iOS settings will be removed in iOS5.1 (so urls like `prefs:root=General&path=Network` will no longer work) So, please aware. – Hlung Feb 23 '12 at 16:41
  • 1
    What would be solution for iOS 7? – Jayprakash Dubey Aug 08 '14 at 11:41
34

From IOS 8 you can call the settings from within app with this:

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

dynebuddha
  • 471
  • 4
  • 9
  • 12
    The above line is directing to **app private settings**. Is there any way to direct to **privacy** section of the device settings? Please comment if you know. This redirection is possible as I saw it in maps app where it directs to location settings in privacy section. – Pavan Kotesh Oct 10 '14 at 15:04
17

It's also work in iOS version > 5.1, but you must add an URL schemes in URL types in Xcode:

enter image description here

Then you can use

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

It's can open system WiFi setting now.

Other path please find in this answer: iOS Launching Settings -> Restrictions URL Scheme.

Community
  • 1
  • 1
Slemon
  • 791
  • 7
  • 12
15

Bad news: As @Hlung and @jasongregori suggested, for iDevices whose OS version >= iOS 5.1 && < iOS 8.0, there is once again NO official/documented way to call the built-in Settings app from a third-party app. Period.

arunit21
  • 670
  • 1
  • 11
  • 25
Di Wu
  • 6,436
  • 3
  • 35
  • 51
  • 18
    I'm agree with this and I also can't make this calls to work.. but some apps are still doing this calls (I'm running iOs 6.1), like Twitter and Flipboard when you are in airplane mode... how do they do it? – Omer Feb 07 '13 at 12:19
  • @Omer This solution is not working for iOS 10 . I am working on Xcode 8, swift 3. Any alternate solution please? – Khadija Daruwala Sep 23 '16 at 07:07
12

Calling the settings app from other app is possible only from iOS 8. So, use the following code

if([CLLocationManager locationServicesEnabled]&&
   [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
  //...Location service is enabled
}
else
{
    if([[[UIDevice currentDevice] systemVersion] floatValue]<8.0)
    {
      UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
      [curr1 show];
    }
    else
    {
       UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
       curr2.tag=121;
       [curr2 show];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if (alertView.tag == 121 && buttonIndex == 1)
 {
  //code for opening settings app in iOS 8
   [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];
 }
}
Teja Kumar Bethina
  • 3,486
  • 26
  • 34
5

from iOS 8, you can redirect with

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

enjoy coding

Mohit Tomar
  • 5,173
  • 2
  • 33
  • 40
0

Just an additional answer to add onto the one's addressing iOS8+. If you're supporting anything below 8, you should check to see if it's supported

BOOL canGoToSettings = (UIApplicationOpenSettingsURLString != NULL);
if (canGoToSettings)
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
Chris
  • 7,270
  • 19
  • 66
  • 110
0

For settings in iOS 9 this is worked for me.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Settings"]];

But make sure you add a url schemes in URL types in

Info tab in app targets.

Narasimha Nallamsetty
  • 1,215
  • 14
  • 16
0

For iOS 10 you can use:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Settings"]];

It is also working on iOS 9!

Ivan Skrobot
  • 311
  • 3
  • 7