How to open Location services screen from setting screen?
51,699
Solution 1
Step 1: Click on project name >> target>> info >> url Types
Step 2:
-(IBAction)openSettingViewToEnableLocationService:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
}
Solution 2
Swift 4.2
Go straight to YOUR app's settings like this:
if let bundleId = Bundle.main.bundleIdentifier,
let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(bundleId)")
{
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
Solution 3
You can open it directly like using below code,
But first set URL Schemes
in Info.plist's URL Type Like:
Then write below line at specific event:
In Objective - C :
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
In Swift :
UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=LOCATION_SERVICES")!)
Hope this will help you.
Solution 4
First:
Add URL
Go to Project settings --> Info --> URL Types --> Add New URL Schemes
See image below:
Second:
Use below code to open Location settings:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
referred from: https://stackoverflow.com/a/35987082/5575752
![Monika Patel](https://i.stack.imgur.com/NyIi2.jpg?s=256&g=1)
Comments
-
Monika Patel almost 2 years
-
Erich Brunner about 7 years@Joe Susnick Do you have a solution for iOS 10? Thanks for any help
-
Joe Susnick about 7 years@EricBrunner yes, I posted above but the url:
App-Prefs:root=Privacy&path=LOCATION
worked for me. -
Erich Brunner about 7 years@Joe Susnick Great. Do I have to distinquish between iOS 8,9 and 10.x or does that work in all versions? Thanks again for your support!
-
Joe Susnick almost 7 years@EricBrunner I've only tested it on 10 but I'm pretty confident it'll work on 9. As far as 8 goes, not sure.
-
Ramis almost 7 yearsAfter implementing it will it pass App Store review guidelines?
-
MMSousa almost 7 yearsin iOS 10 I need use the URL App-Prefs:root=Privacy&path=LOCATION.
-
Tà Truhoada over 6 yearsEasier: UIApplication.shared.openURL(URL.init(string: UIApplicationOpenSettingsURLString)!)
-
user25 over 6 years@MMSousa in IOS 11
URL(string: "App-prefs:root=LOCATION_SERVICES")
still works without problems... -
user25 over 6 years@TàTruhoada it's useless if Location services are disabled, what you wrote here it's for app location permission but not for enable/disable locations services itself.. you can't change location permissions for your app if location services itself are disabled
-
MartijndeM about 6 yearsApple prohibits the use of this API now, you might not want to use it anymore since it may lead to rejection by app review: stackoverflow.com/questions/49059668/…
-
Ted about 6 yearsAs of May 25, 2018 our app got rejected because of using prefs:root under Guideline 2.5.1 - Performance - Software Requirements
-
Ted about 6 yearsAs of May 25, 2018 our app got rejected because of using prefs:root under Guideline 2.5.1 - Performance - Software Requirements
-
Ted about 6 yearsAs of May 25, 2018 our app got rejected for using prefs:root under Guideline 2.5.1 - Performance - Software Requirements
-
F.O.O about 3 yearsquestion asks about going to the location services page not the app settings page
-
RsD about 2 yearsApp Rejected by Apple.