[英]How to open settings page instead of App settings in ios
So I want to open settings page (VPN) and not app settings on iPhone所以我想打开设置页面 (VPN) 而不是 iPhone 上的应用程序设置
I stumbled upon this articles that talks about iOS URL schemas for App settings.我偶然发现这篇文章讨论了应用程序设置的 iOS URL 模式。
https://medium.com/p/20871139d72f https://medium.com/p/20871139d72f
Based on that, I added prefs
to URL schema and then wrote this code基于此,我将
prefs
添加到 URL 模式,然后编写了这段代码
NSURL *url = [NSURL URLWithString:@"prefs:root=General&path=About"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
but this didn't work, So I worked with App-Refs
and modified my code to this但这没有用,所以我使用
App-Refs
并将我的代码修改为
NSURL *url = [NSURL URLWithString:@"App-Prefs:root=General&path=About"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
This open setting, but not the About
(simulator doesn't have Vpn).此打开设置,但不是
About
(模拟器没有 Vpn)。
Can someone tell me how I can open VPN
in settings on iOS.谁能告诉我如何在 iOS 的设置中打开
VPN
。
Also, I read Apple rejects app if we use prefs
.另外,我读到 Apple rejects app if we use
prefs
。 if that's the case, what's the point of having URL schema?如果是这样,那么拥有 URL 模式有什么意义呢?
Update: So VPN apps add VPN and can also open the VPN page in settings (sharkVpn) so I think it is possible?更新:所以 VPN 应用程序添加了 VPN,并且还可以在设置 (sharkVpn) 中打开 VPN 页面,所以我认为这是可能的?
This might be one of those scenarios where you have to put some UX around things rather than being able to automate things perfectly.这可能是您必须围绕事物放置一些 UX 而不是能够完美地自动化事物的场景之一。 Ask the user to do something in VPN settings, then have a
Continue
button.要求用户在 VPN 设置中做一些事情,然后有一个
Continue
按钮。
I seem to remember running into the same problem for a Swift app.我似乎记得在 Swift 应用程序中遇到过同样的问题。 In my case I wanted to ensure a prerequisite of a secured device before storing OAuth tokens in the device keychain.
在我的例子中,我想在设备钥匙串中存储 OAuth 令牌之前确保安全设备的先决条件。
In my blog post I therefore presented the view in the Secured Device Prerequisite
section.因此,在我的 博文中,我在
Secured Device Prerequisite
部分介绍了该视图。 Nothing amazing in this answer, but at least you can unblock yourself, without anything that goes against Apple approval.这个答案没什么了不起的,但至少你可以解锁自己,没有任何违反苹果批准的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.