需要获得超过20个区域监控通知 [英] Need to get more than 20 notification for Region Monitoring

查看:235
本文介绍了需要获得超过20个区域监控通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个用户可以设置多个位置的应用程序。当用户进入Enter或Leave特定位置边界时,我成功显示通知。

I'm developing an application where user can set multiple locations. I get succeed to show notifications when user get Enter or Leave specific location boundary.

现在,我需要为所有已保存的位置提供监控,而且可能需要数百甚至更多。我读过Apple论坛以及许多iOS设备只允许20个区域监控的地方。

Now, there is situation that i need to provide monitoring for all saved locations and it can be hundreds and more. I've read in Apple Forum and many where that iOS devices allow only 20 Region Monitoring.

我开发的代码超出了这种情况。
我设置了 locationManager.distanceFilter = 200; ,当我获得位置更新时。首先,我已停止所有区域监控,并按最近位置的条件停止,并再次启动20个已保存位置的区域监控。

I've develop my code to exceed this situation. I've set locationManager.distanceFilter = 200; and when i get update for location. Firstly, i've stop all Region Monitoring and by conditions for nearest locations and again start Region Monitoring for 20 saved locations.

我认为上述解决方案可能导致丢失任何已保存的位置停止并再次重新启动区域监控时的位置。
所以,请提供任何其他更好的解决方案来解决区域监控问题的这20个通知。

I think above solution may cause for missing any saved location while stopping and again re-starting Region Monitoring. So, please provide me any other better solution to solve this only 20 notifications for Region Monitoring problem.

祝你有愉快的一天。!! ..

Have a nice day .!!..

推荐答案


  1. 拥有一个NSMutableArray,其中包含您要监控的所有区域+20。

  2. 收听重要的位置更新。

  3. 当您获得位置更新时,如果您所有区域的NSMutableArray超过20,则停止监控所有受监控的区域并计算使用harvesine公式的20个最近区域:

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.

注意:如果半径打开,此距离将以千米为单位米然后将半正方法结果乘以1000,以便将其转换为米。


  1. 开始监控20个最近区域的结果列表。

这样您就可以根据您的位置始终监控最近的20个区域。能够监控超过20个,因为它会将监控区域始终更改为最近的20个区域。

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.

这篇关于需要获得超过20个区域监控通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆