I have an app that shows some data based on user's location. And it had been working fine with Swift2 and iOS9. Now none of the CLLocationManager delegate's functions are being called. Here's my code:
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self //locationManager is being initialized at the top of class file and is not nil
locationManager.requestAlwaysAuthorization()
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
locationManager.startUpdatingLocation() //This line executes from viewDidLoad, but not from delegate function
}
func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) { //This is never called
if CLLocationManager.authorizationStatus() != .authorizedWhenInUse {
locationManager.requestWhenInUseAuthorization()
}else{
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { //This is never called
if updatingLocation == true {
//if location is updating, go next step
}
}
I have enabled Privacy - Location Always Usage Description and Privacy - Location When In Use Usage Description in my Info.plist. To test my code, I've also tried to call requestLocation, which should also launch didUpdateLocations, but it didn't. Maybe I'm missing something, but it seems nothing has been changed about CLLocationManager handling for iOS10.
UPD: More code
class HomeViewController: BaseViewController, CLLocationManagerDelegate {
var locationManager = CLLocationManager()
var updatingLocation = true
//other stuff
}