iOS 启动设置 -> 限制 URL 方案
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8246070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS Launching Settings -> Restrictions URL Scheme
提问by kturner
I've recently discovered the awesome iOS5 custom Settings URL Scheme, which can be explained in detail at this great website.
我最近发现了很棒的iOS5 自定义设置 URL 方案,可以在这个很棒的网站上详细解释。
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 Restrictionspath via the path
parameter:
但似乎无法通过参数直接路由到Restrictions路径path
:
[[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).
任何见解将不胜感激。我试图让用户启用应用内购买,而不是让用户手动点击限制(不是很明显)。
回答by Henri Normak
AS @Nix Wang's ANSWER THIS IS NOT WORK IN IOS 10
AS @Nix王的回答是不行的在IOS 10
WARNING: This method will not work for devices running iOS 5.1 and greater - See Hlung's comment below.
警告:此方法不适用于运行 iOS 5.1 及更高版本的设备 - 请参阅下面的 Hlung 评论。
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.
path
组件的名称可能与实际部分的名称不同,但也有可能您当前无法直接从 URL 访问该部分。我发现了一个可能的 URL 列表,但它没有限制,也许只是还没有找到。
List of currently known URLs in the Settings app:
设置应用程序中当前已知的 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=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
- prefs:root=General&path=关于
- prefs:root=General&path=ACCESSIBILITY
- 首选项:root=AIRPLANE_MODE
- prefs:root=General&path=AUTOLOCK
- prefs:root=General&path=USAGE/CELLULAR_USAGE
- 首选项:根=亮度
- prefs:root=General&path=蓝牙
- 首选项:root=General&path=DATE_AND_TIME
- 首选项:root=FACETIME
- 首选项:root=一般
- prefs:root=General&path=Keyboard
- 首选项:root = CASTLE
- 首选项:root=CASTLE&path=STORAGE_AND_BACKUP
- prefs:root=General&path=INTERNATIONAL
- 首选项:root=LOCATION_SERVICES
- 首选项:root = ACCOUNT_SETTINGS
- 首选项:root=音乐
- 首选项:root=音乐&路径=EQ
- prefs:root=MUSIC&path=VolumeLimit
- prefs:root=General&path=Network
- 首选项:root=NIKE_PLUS_IPOD
- 首选项:root=注意
- 首选项:root=NOTIFICATIONS_ID
- 首选项:root=电话
- 首选项:root=照片
- prefs:root=General&path=ManagedConfigurationList
- prefs:root=General&path=Reset
- prefs:root=声音&路径=铃声
- 首选项:root = Safari
- prefs:root=General&path=Assistant
- prefs:root=声音
- prefs:root=General&path=SOFTWARE_UPDATE_LINK
- 首选项:root = STORE
- 首选项:root=推特
- prefs:root=General&path=USAGE
- 首选项:根=视频
- prefs:root=General&path=网络/VPN
- 首选项:root=壁纸
- 首选项:root=WIFI
- 首选项:root=INTERNET_TETHERING
回答by Jason Moore
As of iOS8 you can open the built-in Settings app with:
从 iOS8 开始,您可以使用以下命令打开内置设置应用程序:
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.
实际的 URL 字符串是@"app-settings:"
. 我尝试将不同的部分附加到字符串(“蓝牙”、“通用”等),但似乎只能链接到主设置屏幕。如果您发现其他情况,请发表回复。
回答by Pedro T?rres
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.
如果您将 prefs URL 方案添加到您的 iOS 应用程序,它将允许您使用我们在 iOS 5 中可以使用的所有方案。我已经在 iOS 9 上对其进行了测试,但我认为它也适用于旧版本。
回答by Nix Wang
Update:
更新:
prefs:
will NOT work since iOS 10.
prefs:
自 iOS 10 起将无法使用。
回答by Dan
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.
是的,看到了这个(以及更多),甚至在测试应用程序中实现了它。确实需要从 Apple 获得明确的消息,但社区共识意见是 Apple 在公开“发现/发布”后在 5.1 中不允许使用它,因此不会接受包含它的应用程序。
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:
2012 年 8 月 1 日更新:通过我的开发者帐户询问 Apple 是否有办法以编程方式启动 WiFi 设置对话框。这是回应:
"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."
“我们的工程师已经了您的请求,并得出结论,鉴于当前的系统配置,没有支持的方法来实现所需的功能。”
回答by Mikhail
In iOS 9it works again!
在iOS 9 中它又可以工作了!
To open Settings > General > Keyboard, I use:
要打开Settings > General > Keyboard,我使用:
prefs:root=General&path=Keyboard
Moreover, it is possible to go farther to Keyboards:
此外,可以更深入地使用键盘:
prefs:root=General&path=Keyboard/KEYBOARDS
回答by Mahesh
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
我想在设置应用程序中打开蓝牙菜单,上面的路径 (prefs:root=General&path=Bluetooth) 对我不起作用。最终为我工作的是
UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=Bluetooth")!)
Make sure you have the prefs
URL Scheme defined first.
确保首先prefs
定义了URL Scheme。
回答by pararmswar Developers
Solution for iOS10. Works fine.
iOS10的解决方案。工作正常。
NSURL *URL = [NSURL URLWithString:@"App-prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
回答by mkeremkeskin
As of iOS10 you can use
从 iOS10 开始,您可以使用
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.
您也可以向其中添加已知网址(您可以在最受好评的答案中看到它们)以打开特定设置。例如下面的打开touchID和密码。
UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root=TOUCHID_PASSCODE")!)