…continuing on from the last post, the fourth of five extra notes to my video2brain video training “iPhone and iOS Application Development Workshop” will cover accuracy and distance filters – with reference to the “myLocation” App developed as part of the course (see course contents):
As already stated in my last post in this series, this is one area where you can provide your users with a “power-saving” option or by default ensure that battery drain is lower for your App than for others.
If we take a look at the init method of our CoreLocationController Class for myLocation, we can limit the amount of updates we’ll receive and hence the reported accuracy by implementing a desired accuracy:
Using a desired accuracy of
will result in the user’s device attempting to achieve a level of accuracy to within 1 kilometer. If an even lower level of accuracy is acceptable we can choose
instead. For the highest level of accuracy possible within the limitations of the device being used, we’ll choose
All possible options for desiredAccuracy are:
– Uses the highest possible level of accuracy available, augmented by additional sensor data. This accuracy level should be used only when the device is connected to an external power supply as power drain will be high.
– The highest level of accuracy for devices running on battery power. Power drain will, however, be high and you should provide a “power-saving” option if possible.
- Accurate to within 10 meters.
– Accurate to within 100 meters.
– Accurate to within one kilometer.
– Accurate to within three kilometers.
Distance filters provide another means for reducing power consumption. A distance filter does not define the accuracy of location data but rather defines when an update will be triggered. For this reason, it makes a great deal of sense to use distance filters to limit the number of updates your App will receive.
The following code shows a distance filter defined for the init method of our CoreLocationController Class for myLocation
The result of adding this filter is that the myLocation App will report new location data updates every time the device is moved 1000m or more, to within an accuracy of 1000m, or 1 kilometer.
You can specify any distance in meters for a distance filter. The default value for distance filters is none –
With a combination of desiredAccuracy and distanceFilter, it’s possible to create a location-aware App with various power consumption schemes and levels of reported location accuracy. Giving your users the choice between high accuracy with high battery drain OR lower accuracy (but still usable) with lower battery drain may well help your App to stand out from other competitive Apps!
Note: These notes were compiled at the time of production of the “iPhone and iOS Application Development Workshop” course and there have since been some exciting updates to the Core Location API. Watch this space for some more iOS 5 updates – coming soon!
If you haven’t seen the course yet, then you have no excuse NOT to buy it now – you can currently buy it for 20% off using the Special discount code: IOSD20 = £17.59 – that’s 3 hours 45 minutes of video training (a lot of coding!) for less than a pizza and a beer! Here’s the link:
Meanwhile, the final part of these extra notes will be released in a few days’ time… Watch this space.
comments are closed.