iOS 启动设置 ->限制 URL 方案
我最近发现了很棒的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
我在这里更新一则新闻。
仅使用“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.
AS @Nix Wang 的回答这在 IOS 10 中不起作用
警告:此方法不适用于运行 iOS 5.1 及更高版本的设备 - 请参阅下面 Hlung 的评论。
path
组件的名称可能与实际部分,但您当前也可能无法直接从 URL 访问该部分。我发现了可能的 URL 列表,但限制不在上面,也许只是还没有找到。设置应用程序中当前已知 URL 的列表:
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:
从 iOS8 开始,您可以使用以下方式打开内置设置应用程序:
实际的 URL 字符串是
@"app-settings:"
。我尝试将不同的部分附加到字符串(“蓝牙”、“常规”等),但似乎只能链接到主“设置”屏幕。如果您发现其他情况,请发表回复。As of iOS8 you can open the built-in Settings app with:
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 方案添加到您的 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.
更新:
prefs:
自 iOS 10 起将不再工作。Update:
prefs:
will NOT work since iOS 10.是的,看到了这个(以及更多),甚至在测试应用程序中实现了它。确实需要从苹果那里得到明确的消息,但社区的一致意见是苹果在公开“发现/发布”后在 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:
在 iOS 9 中它又可以工作了!
打开设置>;一般>键盘,我使用:
此外,还可以进一步走向键盘:
In iOS 9 it works again!
To open Settings > General > Keyboard, I use:
Moreover, it is possible to go farther to Keyboards:
我想在设置应用程序中打开蓝牙菜单,但上述路径 (prefs:root=General&path=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
Make sure you have the
prefs
URL Scheme defined first.iOS10 的解决方案。工作正常。
Solution for iOS10. Works fine.
从 iOS10 开始,您可以使用它
来打开常规设置。
您还可以添加已知的网址(您可以在最受支持的答案中看到它们)以打开特定设置。例如下面的一个打开 touchID 和密码。
As of iOS10 you can use
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.
这是我发现的其他内容:
定义了“prefs”URL方案后,“prefs:root=Safari&path=ContentBlockers”正在模拟器上工作(iOS 9.1 English ),但不适用于模拟器(简体中文)。它只会跳转到 Safari,但不会跳转到内容拦截器。如果您的应用程序是国际化的,请小心。
更新:不知道为什么,现在我无法再跳入ContentBlockers,相同的代码,相同的版本,现在不起作用。 :(
在真实设备上(我的是 iPhone 6S 和 iPad mini 2),“Safari”应该是“SAFARI”,“Safari”在真实设备上无法工作,“SAFARI”现在可以工作在模拟器上:
到目前为止,没有发现 iPhone 和 iPad 之间有任何差异。
Here is something else I found:
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. :(
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:
So far, did not find any differences between iPhone and iPad.
适用于 IOS 10 上的应用程序通知设置(已测试)
Works Fine for App Notification settings on IOS 10 (tested)
iOS 10
使用
app-prefs:
请参阅 gist
iOS 10
Use
app-prefs:
See gist
在 iOS16 / Swift 5 中跳转某些子集视图,例如电池设置:
In iOS16 / Swift 5 to jump certain subsetting view, e.g. Battery setttings: