我使用此代码重定向到该位置的 iOS 设置:
NSURL *url = [NSURL URLWithString:@"App-Prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
但它只是重定向到设置,而不是位置或蓝牙设置。有人知道是否有办法重定向到 iOS 位置设置吗?
谢谢
最佳答案
将 url
声明为:
NSURL *url = [NSURL URLWithString:@"App-Prefs:root=LOCATION_SERVICES"];
因此:
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL: url];
}
注意:
上述方法应该适用于 iOS 10.x 及更低版本(您可以检查: How to programmatically open the WIFI settings in Objective-C on iOS 10 )。但是,Apple 不支持“app-prefs”URL 方案!首选项 URL 被视为私有(private) API,唯一记录的首选项 URL 是 UIApplicationOpenSettingsURLString
。显然,这与所使用的编程语言无关;相关:
- Swift 4 - IOS 11 / “Apps-prefs=root” function not working
- IOS 11 / "Apps-prefs=root" function not working after update to Swift 3
粗略地说,您无法在 iOS 11 上再进行此类导航。
关于ios - 打开位置设置在 iOS 11 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49486705/