Working with iBeacon Sensors

Find, monitor and get metadata associated with the sensors

Once the device registration is complete, you can start looking for sensors, get the associated metadata and perform actions on iBeacon events.

Find/Monitor sensors near your location

LPBeaconManager *lpBeaconManager = [LPBeaconManager sharedInstance];
CLLocationCoordinate2D currentLocation = [lpBeaconManager currentLocation];
[lpBeaconManager findSensorsByLocation:currentLocation.latitude
 	andLongitude:currentLocation.longitude
 	didComplete:^(NSArray *sensors, BOOL success) {
    if(!success){
      return;
		}
    for(LPSensor *sensor in sensors){
      [[LPBeaconManager sharedInstance] monitorRegion:sensor.uuid
       andMajor:sensor.major.intValue
       andMinor: sensor.minor.intValue];
    }
  }];

Find/Monitor sensors by metadata

Sensors registered with the LumenPath API can be associated with metadata. This metadata can then be used when looking up a set of sensors.

In the example below, the application looks up all sensors that have the metadata namespace/key => store/reception_desk and starts monitoring them.

LPBeaconManager *lpBeaconManager = [LPBeaconManager sharedInstance];
NSString *ns = "store";
NSString *key = "reception_desk";

[lpBeaconManager findSensorsByMetadata:ns
 andKey: key
 andValue: nil
 didComplete:^(NSArray *sensors, BOOL success) {
    if(!success){
      return;
		}
    for(LPSensor *sensor in sensors){
      [[LPBeaconManager sharedInstance] monitorRegion:sensor.uuid
       andMajor:sensor.major.intValue
       andMinor: sensor.minor.intValue];
    }
  }];

In the next example, the application looks up all sensors that have the metadata namespace/key => store/store_id with value '1234' and monitors them.

LPBeaconManager *lpBeaconManager = [LPBeaconManager sharedInstance];
NSString *ns = "store";
NSString *key = "store_id";
NSString *value = "1234";

[lpBeaconManager findSensorsByMetadata:ns
 andKey: key
 andValue: value
 didComplete:^(NSArray *sensors, BOOL success) {
    if(!success){
      return;
		}
    for(LPSensor *sensor in sensors){
      [[LPBeaconManager sharedInstance] monitorRegion:sensor.uuid
       andMajor:sensor.major.intValue
       andMinor: sensor.minor.intValue];
    }
  }];