Monika Patel Monika Patel - 5 months ago 19
iOS Question

How to open Location services screen from setting screen?

I want to open location service screen programmatically to turn on service.
enter image description here

This screenshot for refrence:

Answer

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.

Comments