2014年12月27日 星期六

區域監控的觸發時機

Monitoring of a geographical region begins immediately after registration for authorized apps. However, don’t expect to receive an event right away, because only boundary crossings generate an event. In particular, if the user’s location is already inside the region at registration time, the location manager doesn’t automatically generate an event. Instead, your app must wait for the user to cross the region boundary before an event is generated and sent to the delegate. To check whether the user is already inside the boundary of a region, use the requestStateForRegion: method of the CLLocationManager class.

要跨過區域才會觸發事件。
如果一開始就在區域內部,則不會觸發進入事件,
解決方法是要用requestStateForRegion去主動查看狀態。

P.S.我在寫iBeacon的時,遇到一模一樣的情況。

沒有留言:

張貼留言