Need to get more than 20 notification for Region Monitoring

点点圈 提交于 2019-11-30 16:26:20
  1. Have an NSMutableArray with all the regions you want to monitor +20.
  2. Listen to significant location updates.
  3. When you get a location update, if the NSMutableArray of all your regions is more than 20 then stop monitoring all regions been monitored and calculate the 20 nearest regions using the harvesine formula:

Harvesine - Objective C

Harvensine - Swift

That will give you the distance between the two locations. After that you could compare that distance with the region radius to know if is inside the region.

Note: This distance will be in kilometers if your radius is on meters then just multiply the haversine method result with 1000 so that it's converted to meters.

  1. Start monitoring the result list of the 20 nearest regions.

This will allow you to always monitor the 20 nearest regions based on your location. Been able to monitor more than 20 since it will change the monitoring regions always to the 20 nearest regions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!