Other Features and Considerations
- Battery Drain. Using the CoreLocation API causes considerable battery drain on an iPhone. Because of this, it's important to use it as little as possible. There are several ways to reduce usage and therefore battery drain:
- Only Check When Needed. By calling StartUpdatingLocation and StartUpdatingHeading only when you need the information, and calling StopUpdatingLocation and StopUpdatingHeading when you're finished with the data, the iPhone can actually turn off the underlying hardware that makes these calls. This can make the battery last significantly longer.
- Set Your Accuracy. By default, the location data given by the iPhone will strive to be as accurate as possible. This may mean trying to poll more satellites, or resolving more Wi-Fi access points, etc. This also can cause significant battery drain. CLLocationManager has a property called DesiredAccuracy that can be set to your desired accuracy of location data. It expects a setting in meters, so setting it to 1000 will give it kilometer level accuracy. Setting to -1 will force it to be as accurate as possible.
- Update Threshold. By default, location and heading data will be updated constantly. You can set a threshold level for how often you want the location and heading to be updated. CLLocationManager exposes the DistanceFilter and HeadingFilter properties, to set location and heading update threshold, respectively.
- CLLocationManager.DistanceFilter. The value, in meters, of how far the device has to move laterally before a location update is sent. A value of -1 will cause it to update continuously.
- CLLocationManager.HeadingFilter. The value, in degrees, of how far the device has to rotate before a heading update is sent. A value of -1 will cause it to update continuously.
- Capabilities. The iPhone user can turn off location services altogether from the settings panel on the iPhone. Some users do this for privacy or battery life reasons. Additionally, the compass was introduced in the iPhone 3Gs model. The CLLocationManager exposes two properties, LocationServicesEnabled, and HeadingAvailable to give you information regarding them:
- CLLocationManager.LocationServicesEnabled. If false, the user has this turned off, and if your application attempts to access location information via StartUpdatingLocation, the user will be given a prompt to allow the application to use location services.
- CLLocationManager.HeadingAvailable. This is false on the versions of the iPhone that do not have a compass built in. If it's false, then you won't be able to get any meaningful heading data.


