Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between didEnterRegion and didRangeBeacons

What is the exact difference between didEnterRegion and didRangeBeacons in terms of use case i mean when i should implement didEnterRegion/didExitRegion and when should i implement didRangeBeacons ?

What are the each delegate method's exact functionality ? From apple's documentation it's not very clear.

- (void)locationManager:(CLLocationManager *)manager
         didEnterRegion:(CLRegion *)region
{
} 

AND

- (void)locationManager:(CLLocationManager *)manager
        didRangeBeacons:(NSArray *)beacons
               inRegion:(CLBeaconRegion *)region
{
}
like image 671
Mihir Mehta Avatar asked Mar 19 '23 06:03

Mihir Mehta


1 Answers

didEnterRegion will be called once when you cross the threshold of the region (i.e. detect the beacon). Once you exit the region (i.e. the beacon is no longer visible) didExitRegion will be called and then didEnterRegion will be called again if you re-enter the region.

didRangeBeacons is called repeatedly while beacons that you are ranging are visible, giving you updated proximity information.

A common strategy is to monitor for beacon regions and once didEnterRegion is called, start ranging that beacon for updates, stopping the ranging once didExitRegion is called.

See also - The Location Programming Guide

like image 140
Paulw11 Avatar answered Apr 02 '23 21:04

Paulw11