Monitor iBeacon beacons in the background

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)

  1. 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

+4
3

iOS . bluetooth, , . , - .

, , , . , . , 15 . , - , , , 15 , , ( - 7,5 )

? iOS. , 30. 20 . - .

: https://developer.radiusnetworks.com/2015/04/21/max-beacon-regions-ios.html

, , , 3 . , :

  • , , , , .
  • 15 , , .
+6

Core Location 20 CLRegion . , 20- .

, NSLocationAlwaysUsageDescription info.plist, requestAlwaysAuthorization , kCLAuthorizationStatusAuthorizedAlways.

, , , .

, location manager monitoredRegions , . , , authorizationStatus, , .

0

This link has the sender and receiver ibeacon application in swift 2.3. Hope this gives you a clear idea of ​​ibeacons.

https://www.dropbox.com/s/g0ixmynkjet0uwj/ibeacons_final%202.zip?dl=0

0
source

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


All Articles