I am developing an iOS application and playing with Apple technology CoreLocationand iBeacon. So far I have used three beacons with different UUIDs. Everything was fine until I decided to add more beacons to my application. Only then did I encounter a strange problem. It was said that one application can control up to 20 regions of the lighthouse immediately, when in the background - however, in my particular case, this number seems to be 3. I tried different approaches, nothing worked. When I shuffled the beacons in their array, the result was what I expected - only the first 3 zones of the beacon activated events didEnterRegionand didExitRegionwhen the application was in the background. This did not apply when it was in the foreground.
Please note the following:
- I have an array of custom beacon objects (consumed from the API)
For each custom beacon object, I create an instance CLBeaconRegionas follows:
let beaconRegion = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: region.uuid)!, identifier: region.uuid)
beaconRegion.notifyOnEntry = true
beaconRegion.notifyOnExit = true
beaconRegion.notifyEntryStateOnDisplay = true
Then I pass this instance to the CLLocationManager method startMonitoringForRegionas follows:
locationManager.startMonitoringForRegion (beaconRegion)
When navigating through the response of the CLLocationManager method, monitoredRegionsI get all the areas of the beacons that I expected with state area 2 (outside)
In addition, I have already added:
NSLocationAlwaysUsageDescription
to Info.plist application
locationManager.requestAlwaysAuthorization()
in the ViewController viewDidLoad method
However, didEnterRegionthey didExitRegiononly start when I'm in the range of any of the first three areas of the lighthouse that I started tracking.
Thank,
Peter Charnoleski