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

只愿长相守 提交于 2019-12-17 06:28:34

问题


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?


回答1:


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



回答2:


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

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




回答3:


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

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.




回答4:


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.




回答5:


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



回答6:


from iOS 8, you can redirect with

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

enjoy coding




回答7:


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



回答8:


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.




回答9:


For iOS 10 you can use:

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

It is also working on iOS 9!



来源:https://stackoverflow.com/questions/4496813/call-the-official-settings-app-from-my-app-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!