Enrico Susatyo
Enrico Susatyo

Reputation: 19790

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:

Upvotes: 7

Views: 2791

Answers (4)

cipherz
cipherz

Reputation: 543

I actually had this problem when I created my CLBeaconRegion with a major and minor as arguments. If you create the beacon region with major and minor arguments and don't have any beacons with those major and minors the beacon list will be empty. In my case, I wanted to dynamically determine the major/minor. Once I init the CLBeaconRegion with just the UUID and Identifier all was well.

Upvotes: 0

Yogesh Kumar
Yogesh Kumar

Reputation: 289

you have to first start beacon monitoring also set notifyEntryStateOnDisplay = YES

self.region1.notifyEntryStateOnDisplay = YES;
[theLocManager startMonitoringForRegion: region1];
[theLocManager startRangingBeaconsInRegion: region1];

That code works just fine for me also in iOS 8.

Upvotes: 0

Enrico Susatyo
Enrico Susatyo

Reputation: 19790

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

Special thanks to nayoso for helping me solve this.

Upvotes: 3

davidgyoung
davidgyoung

Reputation: 64916

Try using the Locate app on your iOS 8 device, and verify you see the beacon. Make sure you have the UUID of the beacon configured into the Locate app properly.

If you do see it on Locate, then I suspect the issue is that permissions are not properly granted to your app on iOS 8. In this case, you should probably post a code snippet showing your setup where you call [self.locationManager requestWhenInUseAuthorization]; and also include a section of your plist file which needs to have something like:

<key>NSLocationWhenInUseUsageDescription</key> <string>Need to use location services</string>

Upvotes: 1

Related Questions