CLLocationUpdate with the automotiveNavigation configuration spams any location changes

I am working with an app for tracking driving activity. Currently, I have code that combines CLLocationManager location updates with motion data from CMMotionActivityManager.

My codebase is not straightforward and requires manual starts/stops, etc. After watching the WWDC session about CLLocationUpdate.liveUpdates (https://developer.apple.com/wwdc23/10180) with the specific LiveConfiguration.automotiveNavigation, I thought it was exactly what I needed. Moreover, the presenter mentioned that it could simplify code and remove the dependency on CMMotionActivityManager.

I downloaded the demo project from here https://developer.apple.com/documentation/corelocation/adopting-live-updates-in-core-location, adapted it for iOS 17, and changed CLLocationUpdate.liveUpdates() to CLLocationUpdate.liveUpdates(.automotiveNavigation). However, the result was not what I expected. I received location updates after waking from a stationary state by lightly touching the device, which is not "automotive." Additionally, the changes to LiveConfiguration do not seem to affect the behavior.

What did I do wrong? Or what is the point of LiveConfiguration that I missed?

Thanks,

Answered by Engineer in 794447022

Like @staninprague said, the activity types are used to fine tune CoreLocation to give you location updates more accurate for your specific use case - for example .automotivewill correct the randomness in the location coordinates by moving them towards roads, because you have declared you are in an automobile.

These activity types do not mean only give me locations if the device is moving in a way that fits the activity type I declared.

So, the behavior you are seeing is expected.


Argun Tekant /  DTS Engineer / Core Technologies

Per here:

https://developer.apple.com/documentation/corelocation/cllocationupdate/liveconfiguration/automotivenavigation

CLLocationUpdate.LiveConfiguration.automotiveNavigation

The value that configures positioning for an automobile following a road network.


It is about accuracy and distance filter requirements for the location module? Also about "glueing" you to the automotive roads or not.

Do you believe this should also discriminate for the .automotive activity only?

I watched this WWDC session a long time ago though.

From the experience with how the current location/motion works, I'd say my apps would miss a lot of driving distance if they rely on discriminating automotive activity solely by Apple's categorisation.

Accepted Answer

Like @staninprague said, the activity types are used to fine tune CoreLocation to give you location updates more accurate for your specific use case - for example .automotivewill correct the randomness in the location coordinates by moving them towards roads, because you have declared you are in an automobile.

These activity types do not mean only give me locations if the device is moving in a way that fits the activity type I declared.

So, the behavior you are seeing is expected.


Argun Tekant /  DTS Engineer / Core Technologies

CLLocationUpdate with the automotiveNavigation configuration spams any location changes
 
 
Q