A recent feature request stipulated that the user’s location be visible in the various different maps that appear within the app. This is a common enough request and very easy to implement, but what does this mean for battery life of the device? The GPS radio on any iOS device is the most battery-intensive onboard radio and so having GPS running frequently is a bad idea. Time to profile the GPS radio usage!

Given that MKMapView is pretty mature having been around since iOS 3.0, I suspected that it would be intelligent enough to only use the GPS when necessary to determine the user’s location, such as first using wifi, the device’s IP address or some other less battery-intensive operation to determine if the user’s location is actually within the bounds of the displayed map before getting a more accurate reading to display on the map view.

It appears, however, that this is not the case. Rather surprisingly, as soon as showsUserLocation is set to YES until the time it is set to NO or the MKMapView is deallocated, the GPS will run hot, sucking up your juice. Not only will it do this when the user’s location is nowhere near the bounds of the map view, but also when the map view is not even visible to the user, so it turns out that it’s pretty important to manage this property carefully if you don’t want to drain your users’ batteries.

Written on June 6th, 2014 , All, Dev & Test, Mobile, Tech, Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

richardrauser.com is proudly powered by WordPress and the Theme Adventure by Eric Schwarz
Entries (RSS) and Comments (RSS).

richardrauser.com