0
votes

I want to build that gets notified (even when in the background) when it gets in range of any iBeacon with a given UUID.

I know I could monitor an individual region for each of my beacons, but if I understand correctly, on iOS, I am limited to 20 monitored regions.

So the other alternative is to monitor a region based solely on its UUID, but then when do I get enter/exit notifications for that region? Whenever I get in range or out of range of any beacon with the same UUID, or only when I get in range of the first one and out of range of the last one?

1

1 Answers

1
votes

If you monitor based on a wildcard region that includes only a ProximityUUID (leaving major and minor nil) then :

  1. You will only get one didEnter callback the first time the first beacon is detected. If a second, third, or additional beacon is detected matching this wildcard region, then you did not get any monitoring callbacks.

  2. You won't get any further callbacks until all beacons matching the wildcard region disappear (this takes at least 30 seconds in the foreground, longer in the background.) At that time, you'll get a call to didExit. After receiving a didExit, you will again be eligible for the callback in (1) above.

If you want more granular callbacks about individual beacons there are a few choices:

  1. Use additional region definitions (up to the 20 allowed) and monitor them all.

  2. Dynamically change the regions you are monitoring when you get a didEnter. This might work if you have a limited number of beacons (e.g. less than 20) matching a particular wildcard region. You could then activate monitoring for each of these sub-regions.

  3. Use ranging APIs. These give you callbacks once per second with a list of all matching beacons seen that match a region. The trick is that this is generally limited to 10 seconds after region transition in the background. But it is possible to extend it to 180 seconds on request, or indefinitely if you declare your app to be a background location app in Info.plist. (If you go this route, there are a few tricks to get this working properly.)