I know an app can launch other apps by using this code: [[UIApplication sharedApplication] openURL:appUrl];
. And I know the scheme of URL to open safari and mail, but I did some searches and found nothing about the scheme of settings.app.
Asked
Active
Viewed 3.4k times
24
-
1possible duplicate of [Opening the Settings app from another app](http://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app) – Flexo Oct 15 '11 at 21:08
-
I think [this question](http://stackoverflow.com/questions/377102/how-do-i-open-the-settings-application-from-my-application) answers it. – Michael Sharek Jul 07 '09 at 05:12
-
1Check this answer : http://stackoverflow.com/questions/28152526/how-do-i-open-phone-settings-when-a-button-is-clicked-ios/34024467#34024467 – vivek takrani Dec 01 '15 at 16:00
4 Answers
34
You can open settings apps programmatically try this(works only from iOS8 onwards).
If you are using Swift:
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString))
If you are using Objective-C
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
For other lower versions(less than iOS8) its not possible to programatically open settings app.

Yatheesha
- 10,412
- 5
- 42
- 45
-
Big thumbs up! This is great. I tested on iOS 7.1 and it crashed the app, sure enough, when running iOS 8 it takes you to Apple Settings – Ethan Parker Oct 16 '14 at 23:02
-
10is there a way to open to the General Settings app (top-level), not drilled down to your own App Settings? – zonabi Jun 03 '15 at 21:01
16
You can use this in iOS versions 5.0 - 5.0.1. It was then deprecated in iOS 5.1.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

Matt Fenwick
- 48,199
- 22
- 128
- 192

davidcann
- 1,360
- 1
- 15
- 17
3
Opening settings apps programmatically is possible only from iOS 8. So, use the following code from http://code-ios.blogspot.in/2014/10/opening-settings-app-from-another-app.html
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
{
NSLog(@"buttonIndex:%d",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
-
Although the user doesn't have much control over it, you may want to add a check for [CLLocationManager authorizationStatus] != kCLAuthorizationStatusRestricted – Anthony F Nov 10 '14 at 20:18
1
Swift 4 version:
if let url = URL(string: UIApplicationOpenSettingsURLString) {
UIApplication.shared.openURL(url)
}

jonaszmclaren
- 2,459
- 20
- 30