Demystifying iOS location-based services to improve accuracy

Gregory Dean explores the several techniques developers can use in unison to provide accurate location coordinates of a device.

From the humble beginnings of the mobile device era, telecommunication providers and application developers have had the ability to geo-locate a device. Early not-so-smart devices used triangulation - more specifically, trilateration - to pinpoint a user's location. As hardware and supporting technologies evolved, satellite-based navigation capabilities were added to mobile devices. Additionally, every current Apple mobile device includes an accelerometer for measuring speed and a magnetometer for determining a device's heading.

Apple's iOS 6 introduced developers to a much-improved Core Location framework (PDF). The new framework takes full advantage of current hardware to provide a robust suite of location-based services. While trilateration or global positioning alone provides reasonable accuracy, Apple uses several techniques in unison to provide accurate location coordinates of the device. To fully appreciate the complexity of iOS location-based services, we need to understand the science and mathematics behind trilateration, assisted global positioning, and Apple's use of crowd-sourced Wi-Fi.


Triangulation and trilateration are two mathematical processes for determining the location of a point. Triangulation uses a process of measuring angles from known locations - such as cell towers - to calculate current position. Trilateration determines the position of a device by calculating the intersection of circles or spheres representing the distance of a device from known locations. The accuracy of these approaches is improved as more fixed locations are used in the calculations.

Signal strength is used to predict the distance of a device from various cell towers. With the cell tower's fixed location known, a distance radius is established. Without the intersection of circles from a second or third cell tower position, we can only determine that the device is located somewhere on the circumference of the distance circle (Figure A). An Omni-directional antenna on the cell tower can narrow down the position of a mobile device, but not close enough to satisfy the requirements of today's iOS apps.

Figure A

As cellular-enabled mobile devices move about, it is common - especially in densely populated areas - for the device to communicate simultaneously with several cell towers. If two cell towers are in communication with the device, we can derive two possible locations from the two intersecting points (Figure B). The best case, however, is to leverage the information from at least three cell towers to pinpoint a location represented by the single intersection of three circles or spheres (Figure C).

Figure B

Figure C

Global Navigation System

Global navigation systems, like GPS, provide the ability to pinpoint a device by using known coordinates of satellites as opposed to cell towers. Trilateration is used to find the intersecting point of spheres to determine the location of a GPS-enabled mobile device. GPS hardware is energy demanding, and can quickly drain the battery of a mobile device. Apple uses the more efficient Assisted Global Positioning (AGPS) process for locating and linking to satellites. With AGPS, satellite positioning is retrieved from a cellular or Wi-Fi connection reducing the amount of time it takes to discover a satellite.


Apple leverages crowd-sourced information to (1) fine tune the accuracy of location-based services on cellular and GPS enabled devices, and (2) enable location-based services on non-cellular or Wi-Fi only devices.

Crowd-sourced Wi-Fi is by far the most innovative approach for determining the location of a mobile device. Apple uses a database of Wi-Fi hotspots and cell tower locations - submitted anonymously by any number of iOS mobile devices - to help determine the coordinates of a single mobile device. Cellular, AGPS, and crowd-sourced Wi-Fi information are used to feed accurate data to iOS location-based services. Apple's iOS Core Location framework makes it possible to perform complex tasks with only a few lines of code.

Using Location-Based Services

The iOS location-based services provide simple methods for determining a device's current location. The first step in using location-based services is to add the Core Location Framework to your iOS project. With the framework linked, you can access the standard location service, significant-change service, and region monitoring capability within your app.

Follow these steps for adding the Core Location Framework (Figure D):

Figure D

Select the "target" app in left navigation of your project window.

Choose the "Summary" tab and scroll down to the Linked Frameworks and Libraries section.

Click the "+" button, select CoreLocation, and click "Add."

With the Core Location Framework linked to your project, add an #import reference for the <CoreLocation/CoreLocation.h> header file in the code files where the location manager object will be created and initialized. Typically, there is only one instance of the location manager object. For this reason, it is common for developers to create the location manager object in the App Delegate implementation file. The App Delegate header file (.h) should resemble Code A.

Code A

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) CLLocationManager *locationManager;
The App Delegate implementation file (.m) is where the location manager object will be created. We synthesize the property, and then create/initialize our object within the method application didFinishLaunchingWithOptions as shown in Code B. If location services are available, we initialize the object.

Code B

#import "AppDelegate.h"
@implementation AppDelegate
@synthesize locationManager = _locationManager;
- (BOOL)application:(UIApplication *)application     didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
if(self.locationManager == nil){
_locationManager=[[CLLocationManager alloc] init];
_locationManager.distanceFilter = kCLDistanceFilterNone;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.delegate = self;
self.locationManager = _locationManager;
if([CLLocationManager locationServicesEnabled]){
[self.locationManager startUpdatingLocation];
return YES;
With the Core Location framework linked, and the location manager object initialized, compile the app to run in the iPhone Simulator. As you can see, the user is prompted to allow location services for this particular app (Figure E).

Figure E

Location-based services are being used to retrieve the current location of a mobile device for social media and marketing applications. Location-based services on iOS 6 offer the ability to monitor shape-based regions and provide real-time feedback for triggering notifications when a device crosses boundaries. Retailers are using geo-fencing strategies in their apps to spawn a notification to a user when he or she is in close proximity to a predefined location - such as a coffee shop.

The Reminders app in iOS 6 uses region monitoring to support location-based reminders. This capability is available for use within any iOS 6 app. The Location Awareness Programming Guide is a great resource for detailed information regarding the standard location service, significant-change location service, and the improved region monitoring capabilities. Apple has distilled a very complex location-deriving technology into a framework that will definitely inspire many great new apps.

Also read:


Gregory Dean is the CTO for the Wilen Group. He has spent the past 25 years in C-level positions setting the tone and direction of technology-driven services organizations. Gregory is constantly researching technologies and developing capabilities to...


>> global positioning alone provides reasonable accuracy. Huh? What is more reasonable than accurate to 2 meters? When I use my WiFi iPAD I can get a 4-20 meter accuracy. When I use my BB with its GPS I usually see 2-3 meter accuracy. Even indoors I usually see less than 4 meters for accuracy. I find that the maps that are superimposed on the screen are less accurate. The sensitivity of my BB beats any Garmin receiver that I have owned. It gets GPS signals inside coffee shops even when I'm sitting 20 feet away from the windows. However deeper inside of buildings, very heavy forests.etc can cause problems. Rural settings only GPS is available as I don't see too many hotspots on I90 between Spokane and Seattle. Go figure.

Mark W. Kaelin
Mark W. Kaelin

Have you created any apps the require location services? Can you think of how location services can help make your next app better?


I have the same issues and frustrations with my in-dash Garmin navigation compared to my iOS device. It would seem that a device made specifically for navigation would out perform a mobile smartphone. GPS systems that use augmentation (NGPS, WAAS, CORS) are supposed to provide coordinates with an accuracy of 10-15 centimeters. Of course, your BB and my iPhone would need to be nuclear powered to support all of the similtaneous communications necessary to make this work. An accuracy of two meters is more than reasonable. When a minimum of three satellites are providing information, the accuracy is consistent. When weather and atmospheric conditions become a factor, we need to look to other methods for determining position. I lose my satellite radio signal when driving under a bridge or through a tunnel. To your point, the accuracy of the location return by the GPS does not matter if the coordinate system of the mapping software isn't accurate. Great stuff! Thanks for the comments.


My understanding is that modern web browsers -- not OSes -- are doing the bulk of the work in determining geolocation. As I hear it, modern web browsers can and do use multiple methods to determine a device's geolocation. Depending on the device, they will dynamically attempt to use a variety of geolocation strategies/technologies -- with varying degrees of success and accuracy. -- in addition to information such as speed, heading and elevation. What is more, developers are allowed to specify an acceptable degree of accuracy.. So, when GPS is not available [or sufficiently accurate], a modern web browser will dynamically try other methods such as triangulation, crowd-sourcing, etc. This is not to say that Apple cannot contribute code that make geolocation application development easier and efficient. By the way, great article [with very helpful visuals on triangulation]!