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

发布于 2024-12-17 16:41:15 字数 582 浏览 1 评论 0原文

我最近发现了很棒的iOS5自定义设置URL方案,可以在这个伟大的网站

我发现这很有效,将用户从我的应用程序引导到“设置”应用程序:

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

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

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

有任何人找到了这方面的文档或者能够使其工作?

任何见解将不胜感激。我试图让用户启用应用内购买,并且不想让用户手动单击“限制”(不是很明显)。

I've recently discovered the awesome iOS5 custom Settings URL Scheme, which can be explained in detail at this great website.

I've found this to work, directing the user to the Settings app from my application:

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

But cannot seem to route directly to the Restrictions path via the path parameter:

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

Has anyone found documentation on this or been able to make this work?

Any insight would be greatly appreciated. I'm trying to take the user to enable in-App purchasing, and would rather not have the user manually click on Restrictions (not very obvious).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

私野 2024-12-24 16:41:16

我在这里更新一则新闻。
仅使用“prefs:”不会被 Apple 拒绝,我对其进行了测试并检查是否已批准进入应用商店(2016 年 8 月)。谢谢。

I am updating one news here.
Using 'prefs:' only is NOT rejected by Apple, I tested it and checked approved to the app store(in Aug, 2016). thx.

情徒 2024-12-24 16:41:15

AS @Nix Wang 的回答这在 IOS 10 中不起作用


警告:此方法不适用于运行 iOS 5.1 及更高版本的设备 - 请参阅下面 Hlung 的评论。

path 组件的名称可能与实际部分,但您当前也可能无法直接从 URL 访问该部分。我发现了可能的 URL 列表,但限制不在上面,也许只是还没有找到。

设置应用程序中当前已知 URL 的列表:

  • prefs:root=General&path=关于
  • 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=蓝牙
  • 首选项:root=General&path=DATE_AND_TIME
  • 首选项:root=FACETIME
  • 首选项:root=General
  • 首选项:root=General&path=键盘
  • 首选项:root=CASTLE
  • 首选项:root=CASTLE&path=STORAGE_AND_BACKUP
  • 首选项:root=General&path=国际
  • 首选项:root=LOCATION_SERVICES
  • 首选项:root=ACCOUNT_SETTINGS
  • 首选项:root=MUSIC
  • 首选项:root=MUSIC&path=EQ
  • 首选项:root=MUSIC&path=VolumeLimit
  • 首选项:root=General&path=网络
  • 首选项:root=NIKE_PLUS_IPOD
  • 首选项:root=NOTES
  • 首选项:root =NOTIFICATIONS_ID
  • 首选项:root=电话
  • 首选项:root=照片
  • 首选项:root=常规&path=ManagedConfigurationList
  • 首选项:root=常规&path=重置
  • 首选项:root=声音&path=铃声
  • 首选项:root=Safari
  • 首选项:root=常规&path=助手
  • 首选项:root=声音
  • 首选项:root=General&path=SOFTWARE_UPDATE_LINK
  • 首选项:root=STORE
  • 首选项:root=TWITTER
  • 首选项:root=常规&路径=使用
  • 首选项:root=视频
  • 首选项:root=常规&路径=网络/VPN
  • 首选项:root=壁纸
  • 首选项:root=WIFI
  • 首选项:root=INTERNET_TETHERING

AS @Nix Wang's ANSWER THIS IS NOT WORK IN IOS 10


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

It's possible that the path component has a different name than the actual section, but it's also possible that you can't currently access that section straight from a URL. I found a list of possible URLs and Restrictions is not on it, maybe it's just not found out yet.

List of currently known URLs in the Settings app:

  • 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=Brightness
  • prefs:root=General&path=Bluetooth
  • prefs:root=General&path=DATE_AND_TIME
  • prefs:root=FACETIME
  • prefs:root=General
  • prefs:root=General&path=Keyboard
  • 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=Phone
  • prefs:root=Photos
  • prefs:root=General&path=ManagedConfigurationList
  • prefs:root=General&path=Reset
  • prefs:root=Sounds&path=Ringtone
  • prefs:root=Safari
  • prefs:root=General&path=Assistant
  • prefs:root=Sounds
  • 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=Wallpaper
  • prefs:root=WIFI
  • prefs:root=INTERNET_TETHERING
蓝眼泪 2024-12-24 16:41:15

从 iOS8 开始,您可以使用以下方式打开内置设置应用程序:

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

实际的 URL 字符串是 @"app-settings:"。我尝试将不同的部分附加到字符串(“蓝牙”、“常规”等),但似乎只能链接到主“设置”屏幕。如果您发现其他情况,请发表回复。

As of iOS8 you can open the built-in Settings app with:

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

The actual URL string is @"app-settings:". I tried appending different sections to the string ("Bluetooth", "GENERAL", etc.) but seems only linking to the main Settings screen works. Post a reply if you find out otherwise.

初相遇 2024-12-24 16:41:15

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

If you add the prefs URL scheme to your iOS app, it will allow you to use all those schemes that we could in iOS 5. I've tested it on iOS 9, but I think it will work on older versions too.

凉城 2024-12-24 16:41:15

更新:

prefs: 自 iOS 10 起将不再工作。

Update:

prefs: will NOT work since iOS 10.

聆听风音 2024-12-24 16:41:15

是的,看到了这个(以及更多),甚至在测试应用程序中实现了它。确实需要从苹果那里得到明确的消息,但社区的一致意见是苹果在公开“发现/发布”后在 5.1 中禁止了它,因此包含它的应用程序将不会被接受。

2012 年 8 月 1 日更新:通过我的开发者帐户询问 Apple 是否有办法以编程方式启动 WiFi 设置对话框。这是回应:

“我们的工程师已审查您的请求并得出结论:
没有支持的方法来实现给定的所需功能
当前发布的系统配置。”

Yep, saw this (and many more), even implemented it in a test application. Really need to get the definitive word from Apple, but the community consensus opinion is Apple disallowed it in 5.1 after it was publicly "discovered/published", so applications containing it won't be accepted.

08/01/12 Update: Asked Apple through my developer account if there is a way to programmatically launch the WiFi Settings dialog. Here is the response:

"Our engineers have reviewed your request and have concluded that
there is no supported way to achieve the desired functionality given
the currently shipping system configurations."

Hello爱情风 2024-12-24 16:41:15

iOS 9 中它又可以工作了!

打开设置>;一般>键盘,我使用:

prefs:root=General&path=Keyboard

此外,还可以进一步走向键盘

prefs:root=General&path=Keyboard/KEYBOARDS

In iOS 9 it works again!

To open Settings > General > Keyboard, I use:

prefs:root=General&path=Keyboard

Moreover, it is possible to go farther to Keyboards:

prefs:root=General&path=Keyboard/KEYBOARDS
鱼忆七猫命九 2024-12-24 16:41:15

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

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

确保您首先定义了 prefs URL 方案。

I wanted to open the Bluetooth Menu in the Settings Application and the above path (prefs:root=General&path=Bluetooth) didn't work for me.
What ended up working for me was

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

Make sure you have the prefs URL Scheme defined first.

蓝天 2024-12-24 16:41:15

iOS10 的解决方案。工作正常。

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

Solution for iOS10. Works fine.

NSURL *URL = [NSURL URLWithString:@"App-prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
为人所爱 2024-12-24 16:41:15

从 iOS10 开始,您可以使用它

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

来打开常规设置。

您还可以添加已知的网址(您可以在最受支持的答案中看到它们)以打开特定设置。例如下面的一个打开 touchID 和密码。

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

As of iOS10 you can use

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

to open general settings.

also you can add known urls(you can see them in the most upvoted answer) to it to open specific settings. For example the below one opens touchID and passcode.

UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root=TOUCHID_PASSCODE")!)
花开雨落又逢春i 2024-12-24 16:41:15

这是我发现的其他内容:

  1. 定义了“prefs”URL方案后,“prefs:root=Safari&path=ContentBlockers”正在模拟器上工作(iOS 9.1 English ),但不适用于模拟器(简体中文)。它只会跳转到 Safari,但不会跳转到内容拦截器。如果您的应用程序是国际化的,请小心。
    更新:不知道为什么,现在我无法再跳入ContentBlockers,相同的代码,相同的版本,现在不起作用。 :(

  2. 在真实设备上(我的是 iPhone 6S 和 iPad mini 2),“Safari”应该是“SAFARI”,“Safari”在真实设备上无法工作,“SAFARI”现在可以工作在模拟器上:

    #if arch(i386) ||拱门(x86_64)
        // 模拟器
        让 url = NSURL(字符串: "prefs:root=Safari")!
    #别的
        // 设备
        让 url = NSURL(字符串: "prefs:root=SAFARI")!
    #endif
    
    如果 UIApplication.sharedApplication().canOpenURL(url) {
        UIApplication.sharedApplication().openURL(url)
    }
    
  3. 到目前为止,没有发现 iPhone 和 iPad 之间有任何差异。

Here is something else I found:

  1. After I have the "prefs" URL Scheme defined, "prefs:root=Safari&path=ContentBlockers" is working on Simulator (iOS 9.1 English), but not working on Simulator (Simplified Chinese). It just jump to Safari, but not Content Blockers. If your app is international, be careful.
    Update: Don't know why, now I can't jump into ContentBlockers anymore, the same code, the same version, doesn't work now. :(

  2. On real devcies (mine is iPhone 6S & iPad mini 2), "Safari" should be "SAFARI", "Safari" not working on real device, "SAFARI" now working on simulator:

    #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)
    }
    
  3. So far, did not find any differences between iPhone and iPad.

情未る 2024-12-24 16:41:15

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

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

Works Fine for App Notification settings on IOS 10 (tested)

if(&UIApplicationOpenSettingsURLString != nil){
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
赴月观长安 2024-12-24 16:41:15

iOS 10

使用 app-prefs:

App-prefs:root=MOBILE_DATA_SETTINGS_ID

请参阅 gist

iOS 10

Use app-prefs:

App-prefs:root=MOBILE_DATA_SETTINGS_ID

See gist

笑饮青盏花 2024-12-24 16:41:15

在 iOS16 / Swift 5 中跳转某些子集视图,例如电池设置:

  if let url = URL(string: "App-prefs:BATTERY_USAGE") {
    UIApplication.shared.open(url) { accepted in
        print(accepted ? "Success" : "Failure")
    }
  }

In iOS16 / Swift 5 to jump certain subsetting view, e.g. Battery setttings:

  if let url = URL(string: "App-prefs:BATTERY_USAGE") {
    UIApplication.shared.open(url) { accepted in
        print(accepted ? "Success" : "Failure")
    }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文