iBeacon Ranging : Can I combine monitoring ?

20:18

Read about Region Monitoring

When we use beacon monitoring we will get only the following information,
  1. Region boundary is crossed, to/out of the region.
  2. Proxmity UID, Major and Minor IDs
When ranging user will get continuous updates within the region in the location Manager’s didRangeBeacons method.

Using ranging we will get an array of beacons which is ordered by approximate distance from the device, with the closest beacon at the beginning of the array. Also we can check the proximity of the beacon ; far, near or immediate.

 - (void)locationManager:(CLLocationManager *)manager  
     didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region  
 {  
   NSUInteger beaconCount = [beacons count];  
   if (beaconCount)  
   {  
     CLBeacon *lowestProximityBeacon = [beacons firstObject];  
     switch (lowestProximityBeacon.proximity) {  
       case CLProximityImmediate:  
         NSLog(@"You are immediate to the Beacon.");  
         break;  
       case CLProximityNear:  
         NSLog(@"You are near to the Beacon.");  
         break;  
       case CLProximityFar:  
         NSLog(@"You are Far from the Beacon.");  
         break;  
       case CLProximityUnknown:  
       default:  
         NSLog(@"Unable to position the Beacon.");  
         break;  
     }  
 }  

Monitoring & Ranging - Combined.

The apple document explains how to combine Monitoring and Ranging, “While a user’s device is inside a registered beacon region, apps can use the startRangingBeaconsInRegion:method of the CLLocationManager class to determine the relative proximity of one or more beacons in the region and to be notified when that distance changes. ”

So it is better to range a particular region once the device is entered to a registered beacon region. Also if the application is killed only region monitoring (region enter/exit event) will work, region ranging is not possible. The killed application will be relaunched in the background when there is a region monitoring event triggered, at that time we can quickly range that particular region.

Apple continues “To promote consistent results in your app, use beacon ranging only while your app is in the foreground. If your app is in the foreground, it is likely that the device is in the user’s hand and that the device’s view to the target beacon has fewer obstructions...”

Read about Background Monitoring

You Might Also Like

0 comments

Popular Posts

Like us on Facebook

Flickr Images