I built an autopilot for my boat, and took it further by writing an IOS app to control it via bluetooth with my phone. Everything was working great, until I thought I'd add the ability to navigate a route. Here's what has me stumped...
I've got location manager generating updates, as long as the phone is moving (ever so slightly) in my hand. I've got the display setup to never sleep, and the phone is plugged in to power. If I put the phone down, I get a few new locations, then the location freezes. The didUpdateLocations delegate is called, but the location never changes.
I've tried a number of settings but no matter what I try, none have solved the still phone issue. My current design uses
self.locationManager?.requestLocation()
sent on at programmable interval, so that I get updates with reasonable spacing. The updates come, but the location is identical if the phone is still (laying on the dash of the boat). If I just "wiggle" the phone a bit, locations come with a new value. If I keep "wiggling the phone, I get new locations every call to requestLocation.
Seems like there is some kind of inactivity timer associated with didUpdataLocations that prevents retrieving new locations. It just re-sends the previous location.
This issue has nothing to do with using requestLocation, since I had the same issue when didUpdateLocations was running on its own timing. I added the code and logic to support requestLocation in an attempt to force a new location.
Has anyone experienced this or have any idea how to force a "new" location when the phone is still?
I'm using Xcode Version 14.3.1 (14E300c) The phone is an iPhone 12 and the deployment target is set to 15.3
Here's how I currently configure location manager... This is one of a number of attempts, but all have the same issue.
if locationManager == nil{
print("****** instantiating locationManager ******")
locationManager = CLLocationManager()
locationManager!.distanceFilter = kCLDistanceFilterNone
// locationManager!.distanceFilter = 3
locationManager!.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
locationManager!.delegate = self
locationManager!.showsBackgroundLocationIndicator = true
locationManager!.startUpdatingLocation()
locationManager!.startUpdatingHeading()
locationManager!.allowsBackgroundLocationUpdates = true
}
}