Chapter 8. Getting a Fix: Core Location

The Core Location framework provides access to the iPhone’s geographical location systems. These include an integrated GPS, WiFi-based location positioning, and tower triangulation. The iPhone is a very location-aware device, and even stores the GPS coordinates to nearby towers in its cache. Using the Core Location framework, you’re able to obtain the device’s longitude and latitude coordinates, altitude, and other important data. Core Location uses a type of streaming notification so that your application receives updates as the GPS ascertains a more accurate fix.

Apple added a basic level of security to the Core Location interface, and when your application attempts to use it, the user will be prompted whether to allow it access to his current location. If the user restricts your application from using Core Location, you’ll need to be prepared to deliver any remaining portions of your application’s functionality without this information, or prompt the user for a zip code or other information. In addition to a user prompt, Apple has incorporated a Core Location blacklist into the iPhone’s firmware. The iPhone will query this list on Apple’s servers whenever it performs a lookup, and will kill any applications that have been blacklisted.

The process of performing a location lookup is relatively power-intensive, as it queries GPS satellites, local towers, and WiFi hotspots, so be conservative in your use of Core Location to avoid draining the ...

Get iPhone SDK Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.