Di Wu
Di Wu

Reputation: 6448

Call the official *Settings* app from my app on iPhone

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?

Upvotes: 46

Views: 41867

Answers (9)

Ivan Skrobot
Ivan Skrobot

Reputation: 311

For iOS 10 you can use:

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

It is also working on iOS 9!

Upvotes: 0

Slemon
Slemon

Reputation: 791

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.

Upvotes: 17

Narasimha Nallamsetty
Narasimha Nallamsetty

Reputation: 1263

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.

Upvotes: 0

Chris
Chris

Reputation: 7310

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]];
}

Upvotes: 0

Di Wu
Di Wu

Reputation: 6448

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.

Upvotes: 15

Mohit Tomar
Mohit Tomar

Reputation: 5201

from iOS 8, you can redirect with

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

enjoy coding

Upvotes: 5

Teja Kumar Bethina
Teja Kumar Bethina

Reputation: 3706

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]];
 }
}

Upvotes: 12

dynebuddha
dynebuddha

Reputation: 471

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

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

Upvotes: 34

mattorb
mattorb

Reputation: 3075

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"]]

Upvotes: 44

Related Questions