首页 文章

iOS启动设置 - >限制URL方案

提问于
浏览
84

我最近发现了一个很棒的iOS5自定义设置URL方案,可以在这个伟大的website中详细解释 .

我发现这个工作,将用户从我的应用程序引导到Settings应用程序:

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

但似乎无法通过 path 参数直接路由到 Restrictions 路径:

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

有没有人找到这方面的文件或能够使这项工作?

任何见解将不胜感激 . 我正在尝试让用户启用应用内购买,而不是让用户手动点击限制(不是很明显) .

13 回答

  • 140

    我在这里更新一条新闻 . 使用'prefs:'只是不被Apple拒绝,我测试并检查批准到应用程序商店(2016年8月) . 谢谢 .

  • 7

    iOS10的解决方案 . 工作良好 .

    NSURL *URL = [NSURL URLWithString:@"App-prefs:root=TWITTER"];
    [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
    
  • 5

    iOS 10

    使用 app-prefs:

    App-prefs:root=MOBILE_DATA_SETTINGS_ID
    

    gist

  • 2

    我想在设置应用程序中打开蓝牙菜单,上面的路径(prefs:root = General&path = Bluetooth)对我不起作用 . 最终为我工作的是

    UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=Bluetooth")!)
    

    确保首先定义了 prefs URL方案 .

  • 47

    从iOS8开始,您可以使用以下命令打开内置的“设置”应用:

    NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
       [[UIApplication sharedApplication] openURL:url];
    }
    

    实际的URL字符串是 @"app-settings:" . 我尝试将不同的部分附加到字符串("Bluetooth","GENERAL"等),但似乎只链接到主设置屏幕工作 . 如果您发现其他情况,请发布回复 .

  • 18

    iOS 9 它再次有效!

    要打开 Settings > General > Keyboard ,我使用:

    prefs:root=General&path=Keyboard
    

    而且,有可能走得更远 Keyboards

    prefs:root=General&path=Keyboard/KEYBOARDS
    
  • 2

    是的,看到了这个(以及更多),甚至在测试应用程序中实现了它 . 真的需要从苹果公司得到明确的一句话,但社区的共识意见是苹果公司在公开“发现/发布”后不允许使用它,因此包含它的应用程序将不被接受 .

    08/01/12 Update: 通过我的开发人员帐户询问Apple是否有办法以编程方式启动WiFi设置对话框 . 以下是回复:

    “我们的工程师已经审查了您的请求,并得出结论,鉴于当前出货的系统配置,没有支持的方法来实现所需的功能 . ”

  • 31

    从iOS10开始,您可以使用

    UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root")!)
    

    打开常规设置 .

    你也可以添加已知的网址(你可以在最受欢迎的答案中看到它们)来打开特定的设置 . 例如,下面的一个打开touchID和密码 .

    UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root=TOUCHID_PASSCODE")!)
    
  • 21

    这是我找到的其他东西:

    • 我定义了"prefs" URL方案后, "prefs:root=Safari&path=ContentBlockers" 正在使用模拟器(iOS 9.1 English ),但不能使用模拟器 (Simplified Chinese) . 它只是跳转到Safari,而不是内容拦截器 . 如果您的应用是国际化的,请小心 .
      更新:Don 't know why, now I can' t再跳进ContentBlockers,相同的代码,相同的版本,现在不起作用 . :(

    • 关于真正的devcies(我的是iPhone 6S和iPad mini 2), "Safari" should be "SAFARI" ,"Safari"无法在真实设备上工作,"SAFARI"现在正在使用模拟器:

    #if arch(i386) || arch(x86_64)
        // Simulator
        let url = NSURL(string: "prefs:root=Safari")!
    #else
        // Device
        let url = NSURL(string: "prefs:root=SAFARI")!
    #endif
    
    if UIApplication.sharedApplication().canOpenURL(url) {
        UIApplication.sharedApplication().openURL(url)
    }
    
    • 到目前为止,没有发现iPhone和iPad之间存在任何差异 .
  • 0

    AS @Nix Wang的回答这不是 IOS 10


    WARNING: This method will not work for devices running iOS 5.1 and greater - See Hlung's comment below.

    path 组件的名称可能与实际部分的名称不同,但's also possible that you can' t当前直接从URL访问该部分 . 我找到了一个可能的URL列表,并且没有限制,可能它还没有找到 .

    “设置”应用中当前已知网址的列表:

    • prefs:root = General&path = About

    • prefs:root = General&path = ACCESSIBILITY

    • prefs:root = AIRPLANE_MODE

    • prefs:root = General&path = AUTOLOCK

    • prefs:root = General&path = USAGE / CELLULAR_USAGE

    • prefs:root =亮度

    • prefs:root = General&path = Bluetooth

    • prefs:root = General&path = DATE_AND_TIME

    • prefs:root = FACETIME

    • prefs:root = General

    • prefs:root = General&path =键盘

    • prefs:root = CASTLE

    • prefs:root = CASTLE&path = STORAGE_AND_BACKUP

    • prefs:root = General&path = INTERNATIONAL

    • prefs:root = LOCATION_SERVICES

    • prefs:root = ACCOUNT_SETTINGS

    • prefs:root = MUSIC

    • prefs:root = MUSIC&path = EQ

    • prefs:root = MUSIC&path = VolumeLimit

    • prefs:root = General&path = Network

    • prefs:root = NIKE_PLUS_IPOD

    • prefs:root = NOTES

    • prefs:root = NOTIFICATIONS_ID

    • prefs:root =电话

    • prefs:root =照片

    • prefs:root = General&path = ManagedConfigurationList

    • prefs:root = General&path = Reset

    • prefs:root = Sounds&path =铃声

    • prefs:root = Safari

    • prefs:root = General&path = Assistant

    • prefs:root =声音

    • prefs:root = General&path = SOFTWARE_UPDATE_LINK

    • prefs:root = STORE

    • prefs:root = TWITTER

    • prefs:root = General&path = USAGE

    • prefs:root = VIDEO

    • prefs:root = General&path = Network / VPN

    • prefs:root =壁纸

    • prefs:root = WIFI

    • prefs:root = INTERNET_TETHERING

  • 42

    如果您将prefs URL方案添加到iOS应用程序,它将会允许你使用我们在iOS 5中可以使用的所有方案 . 我已经在iOS 9上测试了它,但我认为它也适用于旧版本 .

  • 2

    适用于IOS 10上的应用程序通知设置(已测试)

    if(&UIApplicationOpenSettingsURLString != nil){
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    }
    
  • 4

    更新:

    prefs: 自iOS 10起无效 .

相关问题