I have location services disabled for my application in the settings panel. I run a test in viewDidLoad in my view controller to see if they are enabled:
if([CLLocationManager locationServicesEnabled]) {
//Do something now
}
This test always passes for some reason. If I try and access location services I get a kCLErrorDenied error for the location manager. What gives?
Am I using the wrong test?
The locationServicesEnabled class method only tests the global setting for Location Services. AFAIK, there’s no way to test if your app has explicitly been denied. You’ll have to wait for the location request to fail and use the CLLocationManagerDelegate method locationManager:didFailWithError: to do whatever you need. E.g.:
See the documentation on the CLError constants in the CLLocationManager class reference for more options.