Closed patricks closed 7 years ago
Hi @patricks
Thanks for sample code and issue report. I will update you as soon as I have any answers 👍
Hi @patricks I have tried your demo and when I was testing it i got this in logs:
Exit region KTKBeaconRegion (proximityUUID: 90DC5409-C9F4-4854-BC38-94367885850E, major: (null), minor: (null), identifier: MainRegion)
EXITING MAIN REGION
DidDetermineState state: Outside
Exit region KTKBeaconRegion (proximityUUID: 90DC5409-C9F4-4854-BC38-94367885850E, major: 666, minor: 777, identifier: SubRegion-666-777)
DidDetermineState state: Outside
... so from this I assume exit was called for both your regions Main
and Sub
.
Only thing I can think of right now is that you have another beacon with same proximity UUID and exit is not called as 1+ beacons with same proximity are still nearby.
Maybe try generating new UUID with something like this: https://www.uuidgenerator.net/ Make sure you are changing proximity UUID on just one beacon and try your sample again. This is what I did. I've downloaded your code, updated 1 beacon and tried it and it worked. Same SDK version, iOS 10.1
Hello @patricks
We've done more testing with @stoprocent and we came to conclusion this looks like a Core Location bug. Your sample in theory should work properly all the time, like @stoprocent said earlier, but it turns out it happens only in certain situations:
when you stop ranging for beacons in all regions once you create the subregion, the exit even will also get called
func beaconManager(_ manager: KTKBeaconManager, didRangeBeacons beacons: [CLBeacon], in region: KTKBeaconRegion) {
print("Ranged beacons count: \(beacons.count) in region: major: \(region.major) minor: \(region.minor)")
print("Monitored regions count: \(beaconManager.monitoredRegions.count) Ranged regions count: \(beaconManager.rangedRegions.count)")
for beacon in beacons {
let b = Beacon(clbeacon: beacon)
if discoveredBeacons.contains(b) {
print("Already discovered beacon")
} else {
print("Adding new beacon and starting monitoring")
discoveredBeacons.insert(b)
startMonitoringForRegion(beacon: beacon)
manager.stopRangingBeaconsInAllRegions()
}
}
}
func beaconManager(_ manager: KTKBeaconManager, didStartMonitoringFor region: KTKBeaconRegion) {
if region.identifier != mainRegionIdentifier {
manager.startRangingBeacons(in: region)
}
}
Additionally, we've rewritten your sample in plain Core Location and got exactly the same result. We'll do more tests, to be 100% sure, and then we'll report this bug to Apple.
Closing this issue as there is nothing we can do more at this moment.
I have build a small demo app to demonstrate, that the didExitRegion delegate method isn't called if I start another KTKBeaconRegion with the same UUID, but with a different major and minor ID.
Please try the demo app for more infos
https://github.com/patricks/kontakt_beacon_monitoring_problem