4

In the settings -> general, there is a switch to turn on/off the location services. In the Maps app, when location services is off, if the user click on the find me button, it pops up an alert and asks the user to turn on location services in the settings. It then exits the app and launch the settings app. How can I do that programmatically in my app?

Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
Brian
  • 235
  • 3
  • 11

3 Answers3

3

As of iOS 5.0 you can open the settings app programmatically using the "prefs://" URL scheme. You are out of luck on earlier versions.

Jon C
  • 605
  • 6
  • 14
1

If you just use location services by [CLLocationManager startUpdatingLocation] it will automatically pop up the alert you describe if Location Services are disabled.

However, there's no way to force showing the alert when your specific app has been rejected from using location services by the user (in iOS 4 by disabling your app in the location settings, in iOS 3 by denying the CoreLocation request at the first 2 starts of the app). You only receive the kCLErrorDenied error in -locationManager:didFailWithError:.

Maps.app does show the alert with a Settings button in this case but it looks like they're using a private API for that.

Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
0

I didn't finish reading the whole question!

However, see: Programmatically opening the settings app (iPhone)

(Original reply: The Settings app doesn't seem to have a custom URL scheme, so it appears that the answer is "no".)

Community
  • 1
  • 1
Wevah
  • 28,182
  • 7
  • 83
  • 72
  • hm, I read that post before, but I'm not sure about which version of API they are refering to. Also, every app that uses google map has the same alert when location services is off. Or is that pop up automatically? – Brian Jun 10 '10 at 19:58
  • I believe that's part of MapKit. – Wevah Jun 10 '10 at 20:25