How to check if location services are enabled for a specific application in iOS 7?

I want to check Location Serviceon on/offfor my application, because when I turn it on locaiton Service to ON, but application service is offso` how can I check it by code.

Help solve my problem.

Thanks at Advance.

+4
source share
2 answers

For those who are trying to do it fast.

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")
}
+13
source

In locationManager: didFailWithError :,

Add this:

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{


    if([CLLocationManager locationServicesEnabled])
    {
        NSLog(@"Enabled");

        if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied)
        {
             NSLog(@"Permission Denied");
        }
    }
 }
+4
source

Source: https://habr.com/ru/post/1537346/


All Articles