location = [[CLLocationManager alloc] init];
location.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
location.distanceFilter = 10 ;
location.delegate=self;
locationEnabledBool = [CLLocationManager locationServicesEnabled];
if (locationEnabledBool ==NO) {
UIAlertView *locationAlert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled"
message:@"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[locationAlert show];
[locationAlert release];
}
else
[location startUpdatingLocation];
The value of locationEnabledBool
is always YES
, independent of whether or not location services are enabled. Can any body help?
instead of
if (locationEnabledBool == NO) {
//give error message
}
try
if ( [CLLocationManager locationServicesEnabled] ==NO || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
//give error message
}
I found this on the link.
Detecting whether location services are enabled for my app
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With