10

I'm doing some test using estimote beacons and regions.

Reading the documentation as I start monitoring a region I'm going to tell my delegate that a specific region is being monitored, however, didEnterRegion and didExitRegion are never fired.

My delegate fires:

-(void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region

and

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

I didn't check if an error occurs into locationManager:didFailWithError:

At the moment I'm using the state to manually run two private methods that work as didEnter and didExit - in this case I'm also able to monitor the region but I didn't get why locationManager:didEnterRegion: and locationManager:didExitRegion: are never called.

Is someone facing the same behavior?

square
  • 162
  • 2
  • 13
Mario Catena
  • 575
  • 1
  • 8
  • 20

3 Answers3

5

There are several items to check. The one that addressed my problem was Enabling Background App Refresh in your device's settings (see screenshot below). I had this disabled as a battery saving measure. Monitoring will not work if this is disabled.

If this doesn't address your problem there is a great post you can read that details all of the items to troubleshoot.

iBeacon StartMonitoringForRegion Doesn’t Work


Background App Refresh

hylander0
  • 1,091
  • 11
  • 25
0

This should work. I would like to see the rest of your code that sets up the monitoring, and I would put NSLog statements in your didEnterRegion didExitRegion and didDetermineState (log the state value, too).

It could be that iOS thinks no region transitions are occurring -- that you are always "in" the region, thus no transition. Transitions can take up to 15 min to occur in the background (although if you are ranging in the foreground it should be within 4 secs for an "out" and 1 sec for an "in". See http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html

You can force an in/out region callback by setting region.notifyEntryStateOnDisplay=YES; on your monitored region, then hit the shoulder button. This should force monitoring callback. If you do this and don't see the log statements I suggested adding above, I would be very surprised.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Hi David, I have set already region.notifyEntryStateOnDisplay=YES; however, you made me think one thing. In case I'm already into the region and I run my app, is didEnterRegion fired? Within locationManager:didDetermineState:forRegion: I can check the state == CLRegionStateInside/CLRegionStateOutside also if I stay already in the reagion so I was expecting enter/exit methods fire in the same way. Probably is working already but I have to test my app in a different way. – Mario Catena Nov 27 '13 at 16:31
  • Mario, setting region.notifyEntryStateOnDisplay=YES is special. It *WILL* cause an *extra* call to all the callback methods when the user wakes up the phone. This is the easiest way I know of to get an extra callback when iOS does not think there is a state change. No, you do not get an extra callback on app startup -- unless you make a call to stop monitoring your region (with the exact same ID) and then start again. Successfully restarting will give you the extra callback, too. – davidgyoung Nov 27 '13 at 19:55
  • Eveything is working fine. I think there is a bit of lag before the exit/enterRegion fire. My device takes a bit before it understands I'm out the region. – Mario Catena Nov 28 '13 at 14:48
  • Great! Do you think your "lag" is consistent with my measurements in this blog post?http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html. I would like to know if you are seeing something different. Thanks, David – davidgyoung Nov 28 '13 at 18:31
0

I've tried almost everything and it didn't work. Then I simply restarted my iPhone...and it started working. Incredible. I had this problem with Estimote Beacons.

Stefano Mondino
  • 1,219
  • 11
  • 15