Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

locationServicesEnabled always return YES

I tested my device (iPod Touch 2G iOS 4.1) if location services are enabled

permitted = [locationManager locationServicesEnabled];

and I always get a YES whether location services are enabled or not. I'm talking about the general button for location services and not the app specific button. On iPad with iOS 3.2.2 everything is working fine.

like image 511
testing Avatar asked Oct 27 '10 14:10

testing


1 Answers

Swift 3.1 function returns -> status:Bool and message:String

func isLocationEnabled() -> (status: Bool, message: String) {
    if CLLocationManager.locationServicesEnabled() {
        switch(CLLocationManager.authorizationStatus()) {
        case .restricted, .denied:
            return (false,"No access")
        case .authorizedAlways, .authorizedWhenInUse:
            return(true,"Access")
        }
    } else {
        return(false,"Turn On Location Services to Allow App to Determine Your Location")
    }
}
like image 179
Kassem Itani Avatar answered Sep 18 '22 02:09

Kassem Itani