1
votes

I have a requirement to Open up my iOS App Specific Location Settings. I am aware that we can Open the General Location Settings through the below:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];*

I have two Questions:

  1. Is the above valid and the right as per Apple guidelines (or) should we just Open up the Settings App and allow the user to change the settings?

  2. My requirement is to open my App's Specific Location Settings - the one that shows "Always", "While Using App", "Never", so that the user can modify the same. Is this possible

Thanks in advance.

2
please refer this link for your requirement developer.apple.com/reference/uikit/…Preson

2 Answers

6
votes

For Swift 3 and above: Plus the Code also checks the ios version and does the job for all versions.

if let url = URL(string: UIApplicationOpenSettingsURLString){
        if #available(iOS 10.0, *){
            UIApplication.shared.open(url, completionHandler: nil)
            print("\n--- in ios 10 ")
        } else{
            UIApplication.shared.openURL(url)
            print("\n--- in ios other than 10 ")
        }
    }

UIApplicationOpenSettingsURLString : Basically opens your app's settings, Also It shows all the Services being used by app Including Locations Services,Mobile Data, Photo Library etc...

Now to add Cocoa Keys to your app i.e. in plist file Here are some url's Cocoa keys for iOS 10, Cocoa Keys from developer.apple

0
votes

This will take the user to the app specific settings screen where location, camera, notifications and any other permissions that were requested by the app are listed for the user to toggle.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Hope this helps.