Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between CLActivityType values - iOS SDK

What is the difference between those values:

CLActivityTypeAutomotiveNavigation,
CLActivityTypeFitness,
CLActivityTypeOtherNavigation,

When assigned to activityType property of CLLocationManager?

Documentation suggest that I should use them according to my purpose of using CLLocationManager, but I gives no hint about difference in algorithm that determine halting location updates.

Quote from documentation:

CLActivityTypeAutomotiveNavigation

[...] This activity might cause location updates to be paused only when the vehicle does not move for an extended period of time.

CLActivityTypeFitness

[...]This activity might cause location updates to be paused only when the user does not move a significant distance over a period of time.

CLActivityTypeOtherNavigation

This activity might cause location updates to be paused only when the vehicle does not move a significant distance over a period of time.

I really cannot see the difference between those descriptions.

Documentation Source:

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/#//apple_ref/c/econst/CLActivityTypeOther

like image 657
Paul Brewczynski Avatar asked Oct 06 '15 08:10

Paul Brewczynski


2 Answers

It seems activityType only affects battery performance while monitoring location. Specifically when it pauses polling location.

Will pause polling when

AutomotiveNavigation - Not moved at all in a long time.

OtherNavigation (e.g. boat / train) - Not moved much in a long time.

Fitness - Not moved much in a shorter period of time.

Other - Presumably will not stop polling.

Reason being

  • For boats or trains they may have stopped, but you could still be walking around inside them so you don't really care about these small updates.

  • For fitness you might have stopped your run but you are still moving around in your house... You don't really want to keep draining your battery.

Other notes

The docs for pausesLocationUpdatesAutomatically further suggest that the activityType only determines if location updates should be automatically paused.

You can help the determination of when to pause location updates by assigning a value to the activityType property.

like image 196
Robert Avatar answered Sep 26 '22 14:09

Robert


Not only does the activityType affect battery life as specified by Robert's answer and Apple official documentation, it might also affect the way in which the coordinates returned might be "snapped" to the closest road under certain conditions.

In short, if you're not using activity type "Other Navigation", and if the location is changing fast (= you're on a vehicle fast enough), and somehow your phone is able to get the information needed through Internet or a local cache, the locations reported by the manager will not be accurate, as they'll be "snapped" to the closest road.

This issue has been reported for all versions of iOS since iOS 6. And the issue seems to appear also if any instance of the locations manager running on the entire system has been set up with an activity type that is not "other navigation": note that the default for that property is "other", which is not the same as "other navigation".

Some references:

  • another post on stackoverflow: Control iOS gps input
  • a blog post: http://regex.info/blog/2016-01-19/2666
  • one openradar issue with no answer: https://openradar.appspot.com/radar?id=6056041628303360
  • and another one: http://openradar.appspot.com/radar?id=2245401
like image 25
Matteo Mecucci Avatar answered Sep 24 '22 14:09

Matteo Mecucci