I met strange case during my test. My application should work on background (it updates location). When I test update location on simulator everything works fine I can see information printed in console, but when I test on device plugged to Mac nothing happen, I can't see any information on console.
Can you explain what is exactly happening? Why test background mode on device didn't work?
To test update location I use GPX files.
Below my code for update location:
func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
if !self.locations.isEmpty {
distance += newLocation.distanceFromLocation(self.locations.last!)
print("distance \(distance)")
}
self.locations.append(newLocation)
if UIApplication.sharedApplication().applicationState == .Active {
if let currentDest = navigationCoordinator.coordinates.first as CLLocationCoordinate2D? {
mapView.clear()
updateViewMapWith(newLocation.coordinate, destLocation: currentDest)
}
}
}