Scott Sarnikowski
Scott Sarnikowski

Reputation: 1489

iOS 7.1 Geofencing and iBeacons stop working

I am working on a location services app and am finding some strange behavior. Once the user confirms using location services, the geofence icon appears in the status bar. Everything works great and I get enter and exit region events whether the app is running, in the background, or not in the background. But at some point the geofence icon disappears and my device is insensitive to the Beacon. Are there any conditions under which the geofence is disabled until I power cycle the device? And power cycling does bring it back.

Upvotes: 1

Views: 619

Answers (2)

user3337849
user3337849

Reputation: 99

I was having a similar problem. My app would work and locate beacons on initial run. When I rebooted, app opened to ScanViewController as expected but did not detect beacon.

I referenced article on StackOverflow, iBeacon: didRangeBeacons stops getting called, must reset device for it to work again and reviewed Apple's WWDC 2013 Video Session "What's new in Corelocation" https://developer.apple.com/videos/wwdc/2013/index.php?id=307

I found additional CLLocation delegate methods:

When you init your beacon region if you set:

   notifyEntryStateOnDisplay = YES;

   //The following delegate method will be called: 

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

    if (state ==CLRegionStateInside) {

       [_locationManager startRangingBeaconsInRegion:region]:

}
     //Your alternative code
}

//To help trouble shoot, I added this delegate methods

-(void) locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *) region withError: (NSError *)error {
}

and

-(void) locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:(CLRegion *) region withError: (NSError *)error {
}

I ran app. It returned no failure errors. I checked settings. Bluetooth was enabled and detecting BT devices.

I checked the status bar for geofencing icon. The geofencing icon was present.

I waited for over 2 minutes and then the app detected the beacons and worked as expected. Sluggish is an understatement. I knew that rebooting should work according to all the iOS 7.1 articles that I read in StackOverFlow and other resources.

I rebooted and waited for the app to detect the beacons. On average it took 2 minutes until beacon detection. I am not sure what is causing this slow response. Since must app responses are measured in fractions of seconds, I am sure that developers may think that their apps are not working.

I suggest if your app does not detect beacons or return failure errors that you wait 2 minutes to see if you app will detect the beacon(s). I hope this helps.

Upvotes: 0

davidgyoung
davidgyoung

Reputation: 64941

This is a newly introduced bug in CoreLocation. Unfortunately, there is no known automated way to fix this. It requires a power cycle or Bluetooth off/on sequence to resolve.

See here.

Upvotes: 1

Related Questions