locationServicesEnabled always return YES

后端 未结 6 1499
臣服心动
臣服心动 2021-02-03 10:28

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

permitted = [locationManager locationServicesEnabled];

and I always

6条回答
  •  花落未央
    2021-02-03 11:01

    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")
        }
    }
    

提交回复
热议问题