Location updates

The central component of the IndoorAtlas location framework is the IALocationManager class, which provides access to IndoorAtlas services.

The IALocationManagerDelegate protocol defines the method to receive location updates. Define the location manager property in the interface section and add the delegate

@interface AppDelegate () <IALocationManagerDelegate>
@property (nonatomic, strong) IALocationManager *manager;
@end

To start the IndoorAtlas location service

  • Create a shared instance of IALocationManager and point the delegate to the receiver.
  • Set the IndoorAtlas ApiKey and Secret (see here).
  • Request location updates.

Here is a code snippet for authenticating and requesting location updates:

- (void)authenticateAndRequestLocation
{
	// Create IALocationManager and point delegate to receiver
	self.manager = [IALocationManager sharedInstance];
	self.manager.delegate = self;

	// Set IndoorAtlas ApiKey and secret
	[self.manager setApiKey:kAPIKey andSecret:kAPISecret];

	// Request location updates
	[self.manager startUpdatingLocation];
}

When location data is received from the service, the location manager reports events to the indoorLocationManager:didUpdateLocations: method of its delegate.

// Delegate method from the IALocationManagerDelegate  protocol.
- (void)indoorLocationManager:(IALocationManager *)manager didUpdateLocations:(NSArray *)locations
{
	(void)manager;

	CLLocation *l = [(IALocation *)locations.lastObject location];
	NSLog(@"position changed to coordinate: %.6fx%.6f",
	    l.coordinate.latitude, l.coordinate.longitude);
}

Advanced features

  • Distance filter It is also possible to filter the location updates by distance. (see the API documentation).