How to open Location services screen from setting screen?

前端 未结 11 2063
别那么骄傲
别那么骄傲 2020-12-04 14:01

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

相关标签:
11条回答
  • 2020-12-04 14:58

    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)
    }
    
    0 讨论(0)
  • 2020-12-04 14:59

    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)
    }
    
    0 讨论(0)
  • 2020-12-04 15:03

    SWIFT 4 tested:

    Only way to avoid getting rejected and open Location Preferences of own app is:

    if let bundleId = Bundle.main.bundleIdentifier,
       let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(bundleId)") {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
    
    0 讨论(0)
  • 2020-12-04 15:03

    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"]];
    }
    
    0 讨论(0)
  • 2020-12-04 15:05

    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.

    0 讨论(0)
提交回复
热议问题