简体   繁体   English

如何从iOS 11 beta版的iOS应用程序中打开位置服务?

[英]How to open Location Services from iOS application for iOS 11 beta?

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0)
{
     NSURL *URL = [NSURL URLWithString:@"App-prefs:root=Privacy&path=LOCATION"];
    [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];           
}

This code works fine for iOS 10.0 to 10.3.3 but when I run this code for iOS 11(beta), application goes into background but Setting page doesn't get opened. 此代码适用于iOS 10.0到10.3.3,但是当我为iOS 11(beta)运行此代码时,应用程序进入后台但设置页面无法打开。

application goes into background but Setting page doesn't get opened. 应用程序进入后台但设置页面无法打开。

It was crash of Settings.app. 这是Settings.app的崩溃。 From iOS 11 Beta 7, the crash has been fixed. 从iOS 11 Beta 7开始,崩溃已得到修复。 But it still cannot open the specific path with scheme like @"App-Prefs:root=Privacy&path=LOCATION". 但它仍然无法打开像@“App-Prefs:root = Privacy&path = LOCATION”这样的方案的特定路径。

I was trying to dig into the de-compiled code of Settings.app(Which is actually Preferences.app). 我试图深入研究Settings.app的解编译代码(实际上是Preferences.app)。 Seems like it still uses the schemes above we tried to use, since I found the scheme strings in same form in de-compiled codes. 好像它仍然使用我们尝试使用的上述方案,因为我在解编译的代码中找到了相同形式的方案字符串。

And it might be added sort of permission control in SpringBoard to manager that which process can open specific path in Settings properly. 并且可能会在SpringBoard中添加一些权限控制来管理哪个进程可以正确地在“设置”中打开特定路径。

Anyway, for now in iOS 11 I can only use 无论如何,目前在iOS 11中我只能使用

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

to open settings. 打开设置。

You should check if iOS can open the URL you're trying to call. 您应该检查iOS是否可以打开您尝试呼叫的URL。 You can do this with if([UIApplication sharedApplication] canOpenURL:URL]]){...} . 您可以使用if([UIApplication sharedApplication] canOpenURL:URL]]){...} If iOS 11 can't do that, you should add an else statement to check for iOS 11 and engineer a new solution. 如果iOS 11无法做到这一点,您应该添加一个else语句来检查iOS 11并设计一个新的解决方案。

All clues point to an iOS bug or change that the developers have not been notified about. 所有线索都指向iOS错误或开发人员未收到通知的更改。 It's beta 10 and this still doesn't work. 它是beta 10,但仍然不起作用。 Best guess, submit a bug report to apple. 最好的猜测,向苹果提交错误报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM