I am using CoreLocation in my application. I want to track significant changes in location and altitude. So I have used startMonitoringSignificantLocationChanges, but not getting altitude.
Here is my code :
Here is my code :
Code Block public class MyLocationManager: NSObject { public var currentLocation = CLLocation() private var locationManager = CLLocationManager() public override init() { super.init() self.configureLocationManager() } private func configureLocationManager() { self.locationManager.delegate = self self.locationManager.pausesLocationUpdatesAutomatically = false self.locationManager.allowsBackgroundLocationUpdates = true self.locationManager.requestAlwaysAuthorization() } public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { self.currentLocation = locations.last ?? CLLocation() let lat: Double = self.currentLocation.coordinate.latitude let long: Double = self.currentLocation.coordinate.longitude let alt: Double = self.currentLocation.altitude let dateTime = self.currentLocation.timestamp print("\n\nLatitude :---- \(lat)") print("Longitude :---- \(long)") print("Altitude :---- \(alt)") print("Date :---- \(dateTime)") } }
Then I run app.
Allow location for Always
Check for location update (Location is updating but not getting altitude)
Sent app in background (Location is updating but not getting altitude)
Kill app / Full closed / Remove from background / Terminated (Location is not updating sometime and not getting altitude)