For the last couple of days, I was pulling my hair out over an issue with
CoreLocation's geofencing features. As I stated earlier, our new app Iris relies heavily on those geofences. When I first implemented them, everything seemed fine. But when I switched to some closer test cases around my area (in GPX format, because why would I leave the house anyway), the events for when a region was entered or exited did not fire anymore. I changed the tracks a few times and I even created a few different GPX tracks to make sure that I did not somehow screw up those coordinates. All solutions Google brought up were similar to what I was using. So I was pretty sure that my approach was still right. Nothing seemed to work, though. I was already convinced that this was one of the more stupid mistakes on my end, like swapped longitude and latitude values.
At this point, I already considered going back to my old, resource-hungry but reliable approach. Luckily, I decided to just take a few minutes to read the documentation on this topic. Sure enough, this was where I found the following part:
The system doesn’t report boundary crossings until the boundary plus a system-defined cushion distance is exceeded. This cushion value prevents the system from generating numerous entered and exited events in quick succession while the user is traveling close the edge of the boundary.
So, this pretty clearly states that the behavior I was experiencing wasn’t a bug or an error on my end but rather intended. The system tries to make sure to not fire any events prematurely in case the user is just passing by or flying over the area, without actually checking-in.
I verified this with the test data included in Ray Wenderlich’s Core Location Tutorial. Works just fine. I had not a chance yet to test this in the real world yet, but I’m confident that it will inform me about those boundary crossings now.
Had I read this a few days earlier I would have saved some fine hours to spend with my son. I’m pretty darn sure I will consult the documentation earlier next time.