Joe*_*ick 44
位置服务App-Prefs:root=Privacy&path=LOCATION对我有用.当我在设备而不是模拟器上进行测试时.
我不会列出我尝试过的不起作用的东西,这是一个很长的清单.
假定位置服务已禁用或权限被拒绝或未确定的用法示例:
if !CLLocationManager.locationServicesEnabled() {
if let url = URL(string: "App-Prefs:root=Privacy&path=LOCATION") {
// If general location settings are disabled then open general location settings
UIApplication.shared.openURL(url)
}
} else {
if let url = URL(string: UIApplicationOpenSettingsURLString) {
// If general location settings are enabled then open location settings for the app
UIApplication.shared.openURL(url)
}
}
Run Code Online (Sandbox Code Playgroud)
小智 18
我已经尝试了以上所有答案,它不适用于iOS11 ..它只是打开设置页面而不是应用程序设置..最后这个工作..
UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)
Run Code Online (Sandbox Code Playgroud)
Swift 4.2:
UIApplication.shared.open(URL(string:UIApplication.openSettingsURLString)!)
Run Code Online (Sandbox Code Playgroud)
参考:https://developer.apple.com/documentation/uikit/uiapplicationopensettingsurlstring?language = swift
Jig*_*iya 11
您可以像使用下面的代码一样直接打开它,
但首先URL Schemes在Info.plist的URL类型中设置如下:
然后在特定事件的下面写一行:
在Objective-C中:
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
Run Code Online (Sandbox Code Playgroud)
在Swift中:
UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=LOCATION_SERVICES")!)
Run Code Online (Sandbox Code Playgroud)
希望这会帮助你.
小智 8
SWIFT 4测试:
避免被拒绝和打开自己的应用程序的位置首选项的唯一方法是:
if let bundleId = Bundle.main.bundleIdentifier,
let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(bundleId)") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Run Code Online (Sandbox Code Playgroud)
Swift 4.2
直接进入你的应用程序设置.不要忘记输入您的包标识符 -
if let bundleId = Bundle.main.bundleIdentifier,
let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(bundleId)")
{
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Run Code Online (Sandbox Code Playgroud)
你想安全吗?使用UIApplicationOpenSettingsURLString,这将打开应用程序设置,没有深层链接。
App-prefs正如许多子评论所说,使用您的应用程序将被拒绝。
https://github.com/mauron85/cordova-plugin-background-geolocation/issues/394
第1步:点击项目名称>>目标>>信息>>url类型
第2步:
-(IBAction)openSettingViewToEnableLocationService:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33807 次 |
| 最近记录: |