Those using the Estimote Default packet type rather than iBeacon for the Proximity Beacons would have noticed that beacon monitoring is rather unreliable, often generating false positives.
If you are facing the problem of didExitRegion and didEnterRegion triggering simultaneously every few minutes, you can use NSOperationQueue as a workaround.
Ninja edit: code
var operationQueue = NSOperationQueue()
let beaconManager = ESTBeaconManager()
func beaconManager(manager: AnyObject, didEnterRegion region: CLBeaconRegion) {
let count = operationQueue.operationCount
if (count > 0) {
operationQueue.cancelAllOperations()
}
else {
let notification = UILocalNotification()
notification.alertBody = "You have entered the region"
notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.sharedApplication().presentLocalNotificationNow(notification)
}
}
func beaconManager(manager: AnyObject, didExitRegion region: CLBeaconRegion) {
let operation1 = NSBlockOperation(block: {
sleep(3)
})
let operation2 = NSBlockOperation(block: {
let notification = UILocalNotification()
notification.alertBody = "You have left the region"
UIApplication.sharedApplication().presentLocalNotificationNow(notification)
}
operationQueue.addOperation(operation1)
operation2.addDependency(operation1)
operationQueue.addOperation(operation2)
}
What other methods have you guys discovered? Do share it here!