By Timothy Judkins

As iOS and Android become more restrictive around location permissions, it is important for mobile app developers to understand the impact of different location settings on the frequency and accuracy of location updates. Deciphering which modes work best for your application is tricky. In order to figure out what works best, we had to roll up our sleeves and do a significant amount of testing to gather data and pick the best strategy.

The iOS and Android developer documentation provide some guidance, but are very vague. For example, iOS’s kCLLocationAccuracyBest setting’s description is “the best level of accuracy available” while kCLLocationAccuracyBestForNavigation is “the highest possible accuracy that uses additional sensor data to facilitate navigation apps.” It is unclear which one is better and what the expected accuracy for each is. Similarly, Android has priority settings like PRIORITY_BALANCED_POWER_ACCURACY for “block level accuracy” and PRIORITY_HIGH_ACCURACY for “the most accurate locations available.” Other settings like distanceFilter (iOS) and smallestDisplacement (Android) affect how often location updates are received by the app, but it is unclear how background vs foreground location affect the location accuracy and performance.

Test Scenario

We performed a set of real world tests on iOS and Android to determine how location settings impact accuracy and update rate. iOS has three main parameters that can be adjusted by the developer for location updates: desiredAccuracy, distanceFilter, and activityType. Android has priority, smallestDisplacement, and interval. We focused on the first two parameters for each which directly affect the accuracy and distance between location updates. Note that activityType was set to otherNavigation for iOS and interval was set to 5000 ms for all tests on Android. We repeated the tests with the app in the foreground and background for iOS. Android was tested using a foreground service for location updates.

OSSettingValues Tested
iOSdesiredAccuracykCLLocationAccuracyHundredMeters
kCLLocationAccuracyNearestTenMeters
kCLLocationAccuracyBest
kCLLocationAccuracyBestForNavigation
iOSdistanceFilter3m
30m
200m
400m
iOSactivityTypeotherNavigation
AndroidpriorityPRIORITY_LOW_POWER
PRIORITY_BALANCED_POWER_ACCURACY
PRIORITY_HIGH_ACCURACY
AndroidsmallestDisplacement3m
30m
200m
400m
Androidinterval5000ms

iOS Results

Figure 1 shows the measured accuracy as reported by the iOS device for each of the combinations of settings. 

Figure 1: Measured accuracy for iOS for various location settings.

Location accuracy is best when the desiredAccuracy is set to kCLLocationAccuracyBest or kCLLocationAccuracyBestForNavigation as would be expected, but there does not appear to be a significant difference between the two options. Accuracy for kCLLocationAccuracyHundredMeters is slightly better than 100m. 

An interesting observation is for kCLLocationAccuracyNearestTenMeters where the accuracy was approximately 10m in all cases except when the distanceFilter was set to 400m. We suspect that the higher distanceFilter setting allowed time for the GPS to turn off between location updates. When the GPS turned back on for an update, it may not have enough time to get a better accuracy measurement. 

Based on these results, if a high level of accuracy is needed, the kCLLocationAccuracyBest or kCLLocationAccuracyBestForNavigation settings work best. However, since Apple does not recommend using kCLLocationAccuracyBestForNavigation unless the device is plugged, kCLLocationAccuracyBest is recommended for that condition

Figure 2: Distance between location updates for iOS for various location settings.

Figure 2 shows the distance between location updates (notated as Update Distance) for each of the combinations of settings. This is computed as the straight line distance between the lat/long of two successive location updates. 

We found, in general, that the update distance is less than or equal to the distanceFilter setting. The location updates tend to be slightly more frequent when kCLLocationAccuracyBest or kCLLocationAccuracyBestForNavigation is used for the desiredAccuracy. There were no differences between foreground and background location updates.

Android Results

Figure 3 shows the measured accuracy as reported by the Android device for each of the combinations of settings. 

Figure 3: Measured accuracy for Android for various location settings.

Location accuracy is best when the priority is set to PRIORITY_HIGH_ACCURACY as would be expected. Accuracy for PRIORITY_BALANCED_POWER_ACCURACY is about 70m on average. The accuracy for PRIORITY_LOW_POWER varies significantly across other settings. The accuracy is much better than the “city” level accuracy described in the documentation, but it could be worse in other scenarios that we did not test. 

Figure 4 shows the distance between location updates (notated as Update Distance) for each of the combinations of settings. 

Figure 4: Distance between location updates for Android for various location settings.

We found, in general, that the update distance is less than or equal to the smallestDisplacement setting when the priority is PRIORITY_HIGH_ACCURACY or PRIORITY_BALANCED_POWER_ACCURACY. The update distance for PRIORITY_LOW_POWER varied quite a bit, similar to how accuracy varied for this priority.  

Conclusions

There are a number of settings available in iOS and Android for location updates. Understanding these settings are critical for a high level or accuracy while being conscious of the potential impact of performance and battery life. 

From our testing, if you need high accuracy, use kCLLocationAccuracyBest on iOS and PRIORITY_HIGH_ACCURACY on Android, always noting that higher accuracy can result in more battery usage. 

The distanceFilter (iOS) and smallestDisplacement (Android) settings can be extremely beneficial. Using a small distance for these settings will ensure more frequent updates (at the cost of more battery usage), while larger distances will get less frequent updates. The app developer will need to balance the need for accuracy and frequency for their given application.