How to open Location services screen from setting screen?

IosObjective CLocation Services

Ios Problem Overview


I want to open location service screen programmatically to turn on service.

enter image description here

Ios Solutions


Solution 1 - Ios

I have tried all the above answers,it's not working on iOS11..it just opens settings page and not the app settings .. Finally this works..

UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)

Swift 4.2:

UIApplication.shared.open(URL(string:UIApplication.openSettingsURLString)!)

Refer: https://developer.apple.com/documentation/uikit/uiapplicationopensettingsurlstring?language=swift

Solution 2 - Ios

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 - Ios

You can open it directly like using below code,

But first set URL Schemes in Info.plist's URL Type Like:

enter image description here

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 - Ios



Do you want to be safe? use UIApplicationOpenSettingsURLString, which will open the app settings, without deep-link.

Using App-prefs your app will be rejected, as many sub comments said. https://github.com/mauron85/cordova-plugin-background-geolocation/issues/394

Solution 5 - Ios

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

Solution 6 - Ios

Step 1: Click on project name >> target>> info >> url Types

enter image description here

Step 2:

-(IBAction)openSettingViewToEnableLocationService:(id)sender
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
}

Solution 7 - Ios

If you set locationManager.startUpdatingLocation() and you have disabled on your iphone, it automatically show you an alertView with the option to open and activated location.

Solution 8 - Ios

Swift 5+
Easy Way Direct Your said application page will open

if let BUNDLE_IDENTIFIER = Bundle.main.bundleIdentifier,
    let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(BUNDLE_IDENTIFIER)") {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

Solution 9 - Ios

Actually there's much simpler solution to that. It'll show your app settings with loction services/camera access, etc.:

func showUserSettings() {
    guard let urlGeneral = URL(string: UIApplicationOpenSettingsURLString) else {
        return
    }
    UIApplication.shared.open(urlGeneral)
}

Solution 10 - Ios

After adding prefs as a url type, use the following code to go directly to the location settings of an application.

if let url = URL(string: "App-prefs:root=LOCATION_SERVICES") {
     UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMonika PatelView Question on Stackoverflow
Solution 1 - IosVijay KarthikView Answer on Stackoverflow
Solution 2 - IosTrev14View Answer on Stackoverflow
Solution 3 - IosJigar TarsariyaView Answer on Stackoverflow
Solution 4 - IosEstevão LucasView Answer on Stackoverflow
Solution 5 - IosRonak ChaniyaraView Answer on Stackoverflow
Solution 6 - IosMonika PatelView Answer on Stackoverflow
Solution 7 - IosNicolas MadridView Answer on Stackoverflow
Solution 8 - IosShakeel AhmedView Answer on Stackoverflow
Solution 9 - IosMateusz GrzegorzekView Answer on Stackoverflow
Solution 10 - IosAmrit SidhuView Answer on Stackoverflow