从 iPhone 上的我的应用程序调用官方 *设置* 应用程序

发布于 2024-10-09 00:33:52 字数 178 浏览 1 评论 0 原文

在我的应用程序中的某一时刻,我想将用户重定向到官方设置应用程序。如果可能的话,我还想直接进入设置应用中的网络部分。

我认为我需要的是设置应用程序的网址方案和构建我的请求的格式。但我怀疑调用这样的官方应用程序是否被禁止。

有人可以帮助我吗?

At one point in my app, I would like to redirect the user to the official Settings app. If possible, I also want go straight to the Network section within the Settings app.

I think what I need is the Settings app's url scheme and the format to construct my request. But I doubt that calling such an official app is forbidden.

Can anyone can help me?

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

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

发布评论

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

评论(9

知你几分 2024-10-16 00:33:52

正如下面的评论所述,这在 iOS 5.1 及更高版本中不再可能。

如果您使用的是 iOS 5.0,则以下情况适用:

现在可以在 iOS 5 中使用“prefs:”url 方案实现这一点。它可以通过网页或应用程序运行。

示例网址:

prefs:root=General
prefs:root=General&path=Network

示例用法:

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

As noted in the comments below, this is no longer possible in iOS version 5.1 and after.

If you are on iOS 5.0, the following applies:

This is now possible in iOS 5 using the 'prefs:' url scheme. It works from a web page or from an app.

example urls:

prefs:root=General
prefs:root=General&path=Network

sample usage:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]]
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]
小矜持 2024-10-16 00:33:52

从 IOS 8 开始,您可以使用以下命令从应用内调用设置:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

From IOS 8 you can call the settings from within app with this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

帅气尐潴 2024-10-16 00:33:52

它也适用于 iOS 版本> 5.1,但是你必须在Xcode中的URL类型中添加一个URL方案:

然后你可以使用

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

它可以打开系统WiFi设置
现在。

其他路径请在此答案中找到: iOS Launching Settings ->限制 URL 方案

It's also work in iOS version > 5.1, but you must add an URL schemes in URL types in Xcode:

enter image description here

Then you can use

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

It's can open system WiFi setting
now.

Other path please find in this answer: iOS Launching Settings -> Restrictions URL Scheme.

埖埖迣鎅 2024-10-16 00:33:52

坏消息:正如 @Hlung 和 @jasongregori 所建议的,对于操作系统版本 >= iOS 5.1 && 的 iDevices < iOS 8.0 中,再次没有官方/记录的方式从第三方应用程序调用内置设置应用程序。时期。

Bad news: As @Hlung and @jasongregori suggested, for iDevices whose OS version >= iOS 5.1 && < iOS 8.0, there is once again NO official/documented way to call the built-in Settings app from a third-party app. Period.

残龙傲雪 2024-10-16 00:33:52

仅可在 iOS 8 中从其他应用程序调用设置应用程序。因此,请使用以下代码

if([CLLocationManager locationServicesEnabled]&&
   [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
  //...Location service is enabled
}
else
{
    if([[[UIDevice currentDevice] systemVersion] floatValue]<8.0)
    {
      UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
      [curr1 show];
    }
    else
    {
       UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
       curr2.tag=121;
       [curr2 show];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if (alertView.tag == 121 && buttonIndex == 1)
 {
  //code for opening settings app in iOS 8
   [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];
 }
}

Calling the settings app from other app is possible only from iOS 8. So, use the following code

if([CLLocationManager locationServicesEnabled]&&
   [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
  //...Location service is enabled
}
else
{
    if([[[UIDevice currentDevice] systemVersion] floatValue]<8.0)
    {
      UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
      [curr1 show];
    }
    else
    {
       UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
       curr2.tag=121;
       [curr2 show];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if (alertView.tag == 121 && buttonIndex == 1)
 {
  //code for opening settings app in iOS 8
   [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];
 }
}
皇甫轩 2024-10-16 00:33:52

从 iOS 8 开始,您可以通过

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

享受编码来重定向

from iOS 8, you can redirect with

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

enjoy coding

薔薇婲 2024-10-16 00:33:52

只是添加到 iOS8+ 的一个额外答案。如果您支持低于 8 的任何内容,您应该检查它是否受支持

BOOL canGoToSettings = (UIApplicationOpenSettingsURLString != NULL);
if (canGoToSettings)
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}

Just an additional answer to add onto the one's addressing iOS8+. If you're supporting anything below 8, you should check to see if it's supported

BOOL canGoToSettings = (UIApplicationOpenSettingsURLString != NULL);
if (canGoToSettings)
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
少跟Wǒ拽 2024-10-16 00:33:52

对于 iOS 9 中的设置,这对我有用。

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

中的“URL 类型”中添加 URL 方案。

但请确保在应用程序目标的“信息”选项卡

For settings in iOS 9 this is worked for me.

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

But make sure you add a url schemes in URL types in

Info tab in app targets.

メ斷腸人バ 2024-10-16 00:33:52

对于 iOS 10,您可以使用:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Settings"]];

它也适用于 iOS 9!

For iOS 10 you can use:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Settings"]];

It is also working on iOS 9!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文