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.
23
votes
I think this question answers it.
- Michael Sharek
possible duplicate of Opening the Settings app from another app
- Flexo
Check this answer : stackoverflow.com/questions/28152526/…
- vivek takrani
4 Answers
33
votes
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.
16
votes
3
votes
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]];
}
}