Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didRangeBeacon called without any beacons found

I registered my own location manager to monitor and range a few beacons:

[self.locationManager startMonitoringForRegion:region];
[self.locationManager startRangingBeaconsInRegion:region];

My understanding is, when one or more beacons is found this delegate method is called:

- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region

This delegate method is indeed called when I turned on my beacon, but the beacons array is empty. Is there any reason why my beacon is not listed in that array?

Here's a screenshot to illustrate this situation:

enter image description here


Other things to note:

  • I used MacBeacon to transmit my beacon signal. I will try to use a real beacon later, but MacBeacon has been working fine for me in iOS 7.
  • I tried delaying ranging until I get didEnterRegion: or didDetermineState: is called, but that still result in the same thing.
  • I have requested location permission from my location manager: [self.locationManager requestWhenInUseAuthorization];.
  • I have a very similar code working fine compiled in Xcode 5/iOS 7 SDK. Is this a specific Xcode 6/iOS 8 behaviour?
  • I have added NSLocationWhenInUseUsageDescription key in my plist.
like image 845
Enrico Susatyo Avatar asked Oct 17 '14 16:10

Enrico Susatyo


1 Answers

Turns out this is because I am not using unique identifier when creating CLBeaconRegion.

Special thanks to nayoso for helping me solve this.

like image 50
Enrico Susatyo Avatar answered Sep 21 '22 10:09

Enrico Susatyo