13

I'm developping my first iOS app, and this uses the user's location.

I know that the device asks the user whether to enable location services for the app, but how do I know if the user has enable it or not?

Abizern
  • 146,289
  • 39
  • 203
  • 257
Quentin DOMMERC
  • 876
  • 1
  • 8
  • 24

1 Answers1

44

Probably

[CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied

should be the answer releated SO questions are:
Checking for iOS Location Services
locationServicesEnabled test passes when they are disabled in viewDidLoad

and yes, according to @albertamg suggestion, if you implement CLLocationManagerDelegate protocol

you will be notified if user deny access to Location Services when you're requesting it
see locationManager:didChangeAuthorizationStatus: and locationManager:didFailWithError: methods

Community
  • 1
  • 1
Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
  • 5
    Also, if the user denies access to location service data to the application, the `CLLocationManager` object reports a `kCLErrorDenied` error to its delegate during subsequent requests. – albertamg Aug 28 '11 at 12:53