【问题标题】:Call the official *Settings* app from my app on iPhone从我在 iPhone 上的应用程序调用官方 *Settings* 应用程序
【发布时间】:2011-05-28 15:55:54
【问题描述】:

在我的应用程序中,我想将用户重定向到官方 Settings 应用程序。如果可能的话,我还想直接进入 Settings 应用中的 Network 部分。

我认为我需要的是 Settings 应用程序的 url 方案和构造我的请求的格式。但我怀疑调用这样的官方应用是被禁止的。

谁能帮帮我?

【问题讨论】:

  • 没有这样的 URL 方案(面向公众)。
  • 现在iOS5中有,下面看我的回答。
  • 能否请您链接文档,是什么确保它是公开的?谢谢。
  • 在此问题中查找设置应用程序的已知网址列表:stackoverflow.com/questions/8246070/…

标签: iphone objective-c settings url-scheme


【解决方案1】:

如下面的 cmets 所述,这在 iOS 5.1 及更高版本中不再可能。

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

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

示例网址:

prefs:root=General
prefs:root=General&path=Network

示例用法:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]]
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]

【讨论】:

  • 老兄,你太棒了!经过一番摸索后,我发现了这个用于 twitter 设置:prefs:root=TWITTER
  • 知道这些调用是否被归类为“未记录”吗?我在文档中找不到它们。你是怎么找到他们的?干杯,
  • @MattyG 是的,当然。事实上,我刚刚读到这篇文章说这些不再适用于 iOS 5.1:macstories.net/news/…
  • 只是一个善意的警告,idownloadblog.com/2011/11/29/iphone-5-1-disables-shortcuts 表示 iOS 设置的所有 url 方案将在 iOS5.1 中被删除(所以像 prefs:root=General&path=Network 这样的 url 将不再起作用)所以,请注意。跨度>
  • iOS 7 的解决方案是什么?
【解决方案2】:

在 IOS 8 中,您可以在应用内调用设置:

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

【讨论】:

  • 以上行指向应用隐私设置。有没有办法直接进入设备设置的隐私部分?如果您知道,请发表评论。这种重定向是可能的,因为我在地图应用程序中看到它指向隐私部分中的位置设置。
  • 非常感谢,这正是我要找的!
【解决方案3】:

iOS > 5.1 也可以,但是你必须在 Xcode 的 URL 类型中添加一个 URL 方案:

然后就可以使用了

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

可以打开系统WiFi设置 现在。

其他路径请在此答案中找到:iOS Launching Settings -> Restrictions URL Scheme

【讨论】:

  • @MichaelDorner -- 这不会被 Apple 拒绝,对吗?
  • @Anton -- 这不会被 Apple 拒绝,对吗?
  • @iOSAppDev 不幸的是,随着 iOS10 的发布,这不再起作用了。但之前的版本已成功上传到 AppStore。
  • @Anton 非常感谢您的确认。我很高兴你回复了。谢谢你:)
【解决方案4】:

坏消息:正如@Hlung 和@jasongregori 所建议的那样,对于操作系统版本>= iOS 5.1 && 的iDevice,再次有NO 官方/记录从第三方应用程序调用内置设置应用程序的方式。期间。

【讨论】:

  • 我同意这一点,我也无法使此调用正常工作.. 但某些应用程序仍在执行此调用(我正在运行 iOs 6.1),例如 Twitter 和 Flipboard,当你处于飞行模式……他们是怎么做到的?
  • @Omer 此解决方案不适用于 iOS 10 。我正在开发 Xcode 8,swift 3。请问有其他解决方案吗?
【解决方案5】:

只能从 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]];
 }
}

【讨论】:

    【解决方案6】:

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

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

    享受编码

    【讨论】:

      【解决方案7】:

      只是添加到 iOS8+ 寻址的附加答案。如果你支持低于 8 的任何东西,你应该检查它是否被支持

      BOOL canGoToSettings = (UIApplicationOpenSettingsURLString != NULL);
      if (canGoToSettings)
      {
          [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
      }
      

      【讨论】:

        【解决方案8】:

        对于 iOS 9 中的设置,这对我有用。

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Settings"]];
        

        但请确保在 URL 类型中添加 url 方案

        应用目标中的信息选项卡。

        【讨论】:

          【解决方案9】:

          对于 iOS 10,您可以使用:

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

          它也适用于 iOS 9!

          【讨论】:

            猜你喜欢
            • 2012-08-22
            • 1970-01-01
            • 1970-01-01
            • 2012-04-24
            • 1970-01-01
            • 2012-12-07
            • 1970-01-01
            • 2010-09-19
            • 1970-01-01
            相关资源
            最近更新 更多