Location manager not monitoring Beacons

436 Views Asked by At

I am not getting region entry and exit events for beacon regions. This is how I add the beacon to the monitoredRegions:

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString: beacon.UUID];
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:      uuid major: (CLBeaconMajorValue) beacon.major  minor: (CLBeaconMajorValue) beacon.minor  identifier:  @"SOME IDENTIFIER"];

[_locationManager startMonitoringForRegion: region];

and events:

- (void) locationManager: (CLLocationManager *) manager didEnterRegion:   (CLRegion *) region
{
    NSLog(@"entered  beacon region");
}

- (void) locationManager: (CLLocationManager *) manager didExitRegion: (CLRegion *) region
{
    NSLog(@"exited beacon region");
}

None of these delegate events are called for this beacon region.

I have tested this with geographical regions and it works but it just does not work for my beacon. Also I have tested the ranging on this same beacon which works.

Are there any known issues with beacon monitoring??

Many thanks

1

There are 1 best solutions below

1
On

Hi @ldsarria Check my steps its working for me

Step 1 : Set delgate in .h file CLLocationManagerDelegate

Step 2:

locationManager = [[CLLocationManager alloc] init];
        locationManager.delegate = self;
        locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        locationManager.distanceFilter = kCLDistanceFilterNone;

Step 3:

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"SOME IDENTIFIER"];
        CLBeaconRegion *region = [[CLBeaconRegion alloc] 
        initWithProximityUUID:uuid identifier:@"com.test.abc"];
                region.notifyEntryStateOnDisplay =YES;
                [locationManager startMonitoringForRegion:region];

Step 4: Set NSLocationAlwaysUsageDescription = "This app needs your location to hunt some treasure."

Cheers!!!