didEnterRegion called with larger radius (iOS)

前端 未结 1 1284
心在旅途
心在旅途 2021-02-06 17:20

I want didEnterRegion to be called with much precision, but I wasn\'t able to do so. Here is what I have done: I used the best values of distanceFilter and desiredAccuracy (most

1条回答
  •  深忆病人
    2021-02-06 18:01

    While in theory accuracies of 5m are possible with the current GPS+ technical gear, it may be that Apple prevents such accuracy for region monitoring for various reasons.

    One is that they always want a good user experience and the 5m accuracy you want is within the accuracy range you will often get from the GPS readings. Thus leaving such a small region could also be on account of lower accuracy readings while the user is still within the region. Apple does cover up for such errors by setting thresholds for posting regionEnter or regionExit notifications. From Apple documentation:

    When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.

    The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters

    Nevertheless since you can ask for high accuracy readings Apple should also take that into account. The alternative might be - as you commented - to use didUpdateLocation: and determine if inside or outside the region. That way you could include a test for location accuracy and only accept an exit/entry when horizontal accuracy is good enough.

    0 讨论(0)
提交回复
热议问题