My first iOS app sent background location updates every minute and drained my phone’s battery in six hours.
There was scarcely any useful advice about how frequently I should retrieve background location updates and what combination of accuracy and frequency was optimal for my intended use case.
Apple’s Energy efficiency guide for iOS apps suggests you “Follow best practices to optimize use of location services for energy efficiency” without offering much practical information about how to do that.
Other documentation from Apple and Expo similarly explain the available options and provide basic power-saving recommendations (e.g., lower desired accuracy, pause location updates automatically) but don’t describe how specific choices impact battery life. For instance, would reducing the accuracy or frequency of updates (or a bit of both) conserve more power (and, if so, how much)?
Here’s what I've learned about choosing between background location services and configurations to optimize iOS app performance and energy efficiency.
Cheatsheet for optimizing iOS background location services. Read on for more detailed recommendations.
Which Apple location service should you choose?
Apple’s core location services include: Standard Location, Visits Location, and Significant-change Location.
1️⃣ Standard Location: gets real-time location updates.
- E.g., track outdoor running routes, provide turn-by-turn navigation instructions.
- You can configure the desired accuracy of the location data and the distance that must be traveled before reporting a new location.
The desired accuracy and distance filter significantly affect power consumption.
2️⃣ Visits Location: monitors the places a user visits and how much time they spend there, and delivers that data at a later time; not intended for real-time location updates.
- E.g., suggest social media content or restaurant recommendations based on frequented places.
- You can configure the activity type linked with location updates to pause location updates accordingly. For example, “automotive navigation” turns off radio hardware until the system detects new movement.
Activity type does not dramatically affect power consumption, although airborne and other can be more energy efficient than automobile or other navigation, default, and fitness, for some use cases.
3️⃣ Significant-change Location: reports location changes once the device moves 500 meters or more from its previous notification location; uses cellular and Wi-Fi radios, not GPS.
- E.g., provide location-based reminders or public transit information, track pets.
- No configurable parameters. However, it’s critical you start and stop Significant-change Location services judiciously because these updates run (and drain the user’s battery) continuously until you stop them.
Apple recommends Significant-change Location as the most energy-conservative but least accurate service.
In practice, Visits Location and some configurations of Standard Location (e.g., accurate to the nearest 100 m or 1 km) services are actually more energy efficient while providing more frequent location updates when compared to Significant-change Location.
For more information about Apple's Core Location framework, check out Getting the user’s location from the Location and Maps programming guide.
How core location services differ in energy consumption
- Visits Location is, on average, the most energy efficient service.
- Standard Location is the most power-hungry service on average; however, some configurations consume the same amount of energy as Visits Location services.
- Significant-change Location service consumes more energy than Visits Location and many Standard Location service configurations!
Optimal Standard Location settings
The most energy-efficient combinations of accuracy and distance filter (i.e., distance that must be traveled before reporting a new location) are:
- accurate to the nearest 1 km with a distance filter of ~0.25–4 km
- accurate to within 100 m with a distance filter of ~0.25 km
Standard Location services – accurate to 1 km or 100 m with a distance filter of 0.25–4 km – are as energy-efficient as Visits Location services.
For services accurate to 1 km or 100 m, setting the distance filter to 0.25–4 km is better than not setting a distance filter (which is equivalent to setting it to zero) or using a lower or higher (!) distance filter.
- A distance filter of zero may be more energy-efficient than ~1–250 m when setting the accuracy to the nearest kilometer or shorter.
Efficient configurations for the highest accuracies
Apple's default desired accuracy (best) and the highest possible accuracy (best for navigation) consume at least 20% more energy when compared to the most efficient accuracies (1 km and 100 m).
- For best and best for navigation, higher distance filters improve energy efficiency, and lower (or no) distance filters increase energy consumption.
- Best and best for navigation retrieve background location updates less frequently and consume more power than when accuracy is set to within 100 m.
For a comprehensive breakdown of energy consumption measured in Joules for various combinations of iOS location service settings, refer to this research paper.
Conclusions
We discussed Apple's Standard Location, Visits Location, and Significant-change Location services; specifically, how they compare in functionality and energy efficiency, as well as how you can configure them to minimize your app's battery usage. Of course, real-world power consumption will differ depending on your use case, your users’ hardware, and so on.
When optimizing your app, also consider the broader context of how your app uses location services.
Take, for example, a startup that aggregated location data from various devices to calculate how quickly buses traversed their network, rather than how quickly individual buses moved between stops. This reduced their Google Maps API usage costs by 94% without sacrificing data quality or utility.
I hope this article helps you identify the most efficient location services and settings for your application. If you have any questions, comments, or any neat tips you'd like to share, please reach out to devs@rangle.io.
Good luck!