从iPhone上的应用程序调用官方*设置*应用程序

Di *_* Wu 46 iphone settings objective-c url-scheme

在我的应用程序中,我想将用户重定向到官方设置应用程序.如果可能,我还想直接进入" 设置"应用中的" 网络"部分.

我认为我需要的是设置应用的网址方案和构建我的请求的格式.但我怀疑是否禁止使用这样的官方应用程序.

任何人都可以帮助我吗?

mat*_*orb 44

如下面的评论中所述,在iOS 5.1及更高版本中不再可能.

如果您使用的是iOS 5.0,则以下内容适用:

现在可以在iOS 5中使用'prefs:'url方案.它适用于网页或应用程序.

示例网址:

prefs:root=General
prefs:root=General&path=Network
Run Code Online (Sandbox Code Playgroud)

样品用量:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]]
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]
Run Code Online (Sandbox Code Playgroud)

  • @MattyG是的,绝对.事实上,我刚读过这篇文章,说这些不再适用于iOS 5.1:http://www.macstories.net/news/ios-5-1-beta-blocks-shortcuts-to-system-settings/ (12认同)
  • 只是一个警告,http://www.idownloadblog.com/2011/11/29/iphone-5-1-disables-shortcuts/表示所有iOS设置的url方案都将在iOS5.1中删除(所以网址如此`prefs:root = General&path = Network`将不再有效)所以,请注意. (10认同)
  • 老兄,你太棒了!经过一番探索,我发现这个用于twitter设置:`prefs:root = TWITTER` (6认同)

小智 35

从IOS 8开始,您可以通过以下方式从应用程序中调用设置:

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

  • 以上行指向**app私人设置**.有没有办法直接到**隐私**部分的设备设置?如果你知道,请评论.我可以在地图应用程序中看到这种重定向,它可以指向隐私部分中的位置设置. (12认同)

Sle*_*mon 17

它也适用于iOS版本> 5.1,但您必须在Xcode中的URL类型中添加URL方案:

在此输入图像描述

然后你可以使用

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
Run Code Online (Sandbox Code Playgroud)

它现在可以打开系统WiFi设置.

其他路径请在此答案中找到:iOS启动设置 - >限制URL方案.


Di *_* Wu 15

坏消息:正如@Hlung和@jasongregori所建议的那样,对于操作系统版本> = iOS 5.1 && <iOS 8.0的 iDevices,再次没有官方/文档方式从第三方应用程序调用内置的设置应用程序.期.

  • 我同意这一点,我也不能让这个电话工作..但是当你处于飞机模式时,一些应用程序仍在执行此调用(我正在运行iOs 6.1),如Twitter和Flipboard ...他们这样做了吗? (18认同)

Tej*_*ina 13

只能从iOS 8调用其他应用程序中的设置应用程序.因此,请使用以下代码

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]];
 }
}
Run Code Online (Sandbox Code Playgroud)


Moh*_*mar 5

从iOS 8开始,您可以重定向

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
Run Code Online (Sandbox Code Playgroud)

喜欢编码

  • 是否有类似的技巧重定向到蓝牙设置? (2认同)