Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLRegionState is UnKnown When i"m in the region

I'm testing iBeacon, I've used didDetermineState: method and the CLRegionState is CLRegionStateUnknown when I'm inside the region, can anybody tell me why?

My Bluetooth is On and detecting the beacons when I range them for CLBeaconStateUnknown, sender and receiver are in range (1 Meter), here is my Implementation

-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{

    switch (state) {
    case CLRegionStateInside:
        currentBeconRegion = (CLBeaconRegion *)region;
        [self.locationManager startRangingBeaconsInRegion:currentBeconRegion];
        NSLog(@"INSIDE the Region");//not logging
        break;
    case CLRegionStateOutside:
        NSLog(@"OUTSIDE the Region");
        break;
    case CLRegionStateUnknown:
    default:
        NSLog(@"Region state UNKNOWN!!!"); //Logging on console
        statusLabel.text = @"Region state UNKNOWN!!!";
    //[self.locationManager stopRangingBeaconsInRegion:beaconRegion];           
    [self.locationManager startRangingBeaconsInRegion:beaconRegion];//Suceessfully ranging the beacon

        break;
    }
}
like image 553
Jhondoe Avatar asked Dec 28 '25 20:12

Jhondoe


1 Answers

You say you are "inside the region" but how do you know the iBeacon is really being detected? Is Bluetooth turned on and working? Has the user allowed location access when prompted?

I would enable iBeacon ranging and log anything detected to verify your device really is seeing the iBeacon. I suspect you will either find you do not detect anything, or perhaps the iBeacon.proximity field will be returning CLProximityUnknown due to a bad calibration.

The didDetermineState gets an extra call even if no beacons have ever been detected when you start up monitoring (or if you awake the screen when notifyEntryStateOnDisplay=YES is set on you region). This is the only case where I would think you might get a CLRegionStateUnknown value. I have never seen this value returned, so I am curious under what conditions it happens. Finding the answers to my questions above may solve this. Please report back!

like image 157
davidgyoung Avatar answered Dec 31 '25 13:12

davidgyoung