I want to check Location Service
is on/off
for my application,because when I turn locaiton Service to ON
but application service is off
so` how can I check it by code.
Please help to solve my problem.
Thanks in Advance.
For those who are attempting to do this in swift.
if CLLocationManager.locationServicesEnabled() {
switch(CLLocationManager.authorizationStatus()) {
case .NotDetermined, .Restricted, .Denied:
println("No access")
case .AuthorizedAlways, .AuthorizedWhenInUse:
println("Access")
default:
println("...")
}
} else {
println("Location services are not enabled")
}
In the locationManager:didFailWithError:,
Add this:
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
if([CLLocationManager locationServicesEnabled])
{
NSLog(@"Enabled");
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied)
{
NSLog(@"Permission Denied");
}
}
}
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