3

I have a very strange behavior in my iOS application. While the beacon monitoring is working fine in most cases, there are sometimes hours where the didEnterRegion and didExitRegion events are fired multiple times in a row. The beacon itself is right next to the phone (about 15cm), so there shouldn't be an didExitRegion at all. I know that it is possible to loose a beacon signal what triggers an exit, but it's triggered about 5 times in 3 minutes (both enter and exit - so 10 calls). This is a very rare behavior and seems to be randomly.

The beacons are from Estimote and set via Estimote App to a broadcasting power of -20dBm what should be about 3.5 meters/ 12ft (according to Estimote App) and an advertising interval of 2000ms.

My init of CLLocationManager

if (! _locationManager) {
    _locationManager = [[CLLocationManager alloc] init];

    if ([_locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
        // Not available in iOS 8
        _locationManager.allowsBackgroundLocationUpdates = YES;
    }

    // For iOS 8
    if ([_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
        [_locationManager requestAlwaysAuthorization];
    }

    _locationManager.pausesLocationUpdatesAutomatically = NO;

    _locationManager.delegate = self;
}

That's how i start monitoring

- (void)startMonitoringForBeaconRegions {
    for (CLBeaconRegion *currentBeaconRegion in _beaconRegions) {
        //default should be YES
        currentBeaconRegion.notifyOnEntry = YES;
        currentBeaconRegion.notifyOnExit = YES;
        [_locationManager startMonitoringForRegion:currentBeaconRegion];
    }

}

Does anyone have a similar behavior with their beacons and maybe a solution ??

Kind regards, Kyaak

Kyaak
  • 41
  • 4

1 Answers1

0

I observed a very occasional similar behavior in my demo/test apps. I experimented with setting beacons to max Tx power and 100 ms advertising interval, and it didn't help, which leads me to believe it might be a bug in Core Location itself. I've seen this erratic behavior with both Estimote SDK (which builds on top of Core Location), but also in pure Core Location.

It ordinarily takes 30 seconds of not "hearing" a beacon for an exit event to trigger, but in situations like these, I was observing enters and exits happening in rapid succession, like it completely ignored the 30-second timer, so I believe this is not actually caused by iOS not being able to "hear" the beacon.

I've also experimented with monitoring for CLCircularRegion instead of CLBeaconRegion (so, a GPS geofence instead of a beacon geofence) set up around my apartment and office, and I've observed the same, sporadic, erratic enters and exits.

Unfortunately, I haven't managed to figure out a fix/workaround for that yet. Maybe if we collectively start opening bug reports with Apple, they'll look into that.

heypiotr
  • 2,139
  • 2
  • 15
  • 22
  • Thanks for conforming this strange behavior. It likely seems to be an Apple bug. Did you managed to do a workaround? – Kyaak Nov 23 '15 at 11:57
  • The only one I've discovered so far is to activate Location background mode and keep ranging running in the background. But that (a) will likely get your app rejected during review, (b) even if it slips through the review, it's gonna incur massive battery drain, and thus will be quickly uninstalled or have Location Services access revoked by its users. So it's only good for hackathons / quick demos. – heypiotr Nov 23 '15 at 12:32
  • Hey guys, I am experiencing similar behaviour, but only when a phone call is on. I am monitoring CLBeaconRegion and the methods: didEnterRegion, didExitRegion and didDetermineState are called randomly only when I start a phone call, e.g. facetime call or voice call. Any ideas what could be the reason of this behaviour? – Adam Studenic Apr 30 '16 at 09:15