DidRangeBeacon called without any beacons

I registered my own location manager to monitor and select multiple beacons:

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

As I understand it, when one or more beacons are discovered, this delegate method is called:

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

This delegate method is actually called when I turned on my beacon, but the array of beacons is empty. Is there a reason why my beacon is not listed in this array?

Here is a screenshot illustrating this situation:

enter image description here


Other notes:

  • I used the MacBeacon to transmit the beacon. I will try to use a real beacon later, but MacBeacon works fine for me in iOS 7.
  • I tried deferring the range until we didEnterRegion: or didDetermineState: but it still leads to the same.
  • I requested a location permission from my location manager: [self.locationManager requestWhenInUseAuthorization]; .
  • I have very similar code that works fine in the Xcode 5 / iOS 7 SDK. Is this the specific behavior of Xcode 6 / iOS 8?
  • I added the NSLocationWhenInUseUsageDescription key to my plist.
+6
source share
4 answers

It turns out that this is because I do not use a unique identifier when creating the CLBeaconRegion .

Special thanks to nayoso for helping me resolve this issue.

+3
source

Try using Find app on your iOS 8 device and make sure you see the beacon. Verify that the beacon UUID is configured correctly in the Locate application.

If you see it in Locate, then I suspect that the problem is that the permissions were not properly granted to your application in iOS 8. In this case, you should probably post a code fragment showing your installation where you call [self.locationManager requestWhenInUseAuthorization]; and also include a section of your plist file, which should have something like:

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

+1
source

you need to start beacon monitoring first, also set notifyEntryStateOnDisplay = YES

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

This code is great for me on iOS 8 as well.

0
source

I really had this problem when I created my CLBeaconRegion with primary and secondary arguments. If you create a lighthouse area with primary and secondary arguments and do not have any lighthouses with these major and minor, the list of lighthouses will be empty. In my case, I wanted to dynamically identify the major / minor. As soon as I started CLBeaconRegion with just the UUID and ID, everything was fine.

0
source

Source: https://habr.com/ru/post/976878/


All Articles