CLLocationManager geo-fencing / startMonitoringForRegion:与startMonitoringForSignificantLocationChanges:对比10分钟startUpdating调用 [英] CLLocationManager geo-fencing/startMonitoringForRegion: vs. startMonitoringForSignificantLocationChanges: vs. 10-minute startUpdating calls

查看:148
本文介绍了CLLocationManager geo-fencing / startMonitoringForRegion:与startMonitoringForSignificantLocationChanges:对比10分钟startUpdating调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个应用程序,该应用程序可以在后台检查人员的位置,查看他们是否在指定位置,并且如果他们是,则将ping发送到服务器。我们不想耗尽用户的精力,因此我们正试图找出最佳解决方案。

I am trying to set up an app that will be able to check people's locations in the background, see if they are at a given location, and send a ping to a server if they are. We do not want to drain the energy of our users, so we are attempting to figure out the best solution.

我已经做了大量的阅读,但我还没有找到关于这些方法的大量信息。我将通过我的理解来了解优缺点

I've done substantial reading and I have not found very much information on these methods. I'll go through the pros and cons as I understand them right now

startMonitoringForSignificantChanges

描述:根据wi-fi和cell tower的变化,系统会唤醒应用程序。

Description: Based off of wi-fi and cell tower changes the system wakes up the app.

Docs


一旦设备从之前的通知移动500米
或更多,应用程序就会收到通知。它不应该比每五分钟更频繁地预期
通知。如果
设备能够从网络中检索数据,则位置管理员
更有可能及时发送通知。

Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.

优点:


  • 电池效率最高

缺点:


  • 取决于Wi-Fi /手机信号塔的变化

  • 只能假设每200米到2公里(如果不是更多,在某些区域)会被召唤

  • 更多关于准确性

  • 因此,不一致和不精确

  • Dependent on wi-fi/cell tower changes
  • Can only assume that this will be called every 200m to 2km (if not more in certain areas)
  • More on accuracy
  • Thus, inconsistent and imprecise

10分钟开始更新或n分钟更新:

10-minute start-updating or "n-minute updating":

描述:这基本上要求应用程序有更多时间,w如果额外的时间即将到期,它会调用[self.locationManager startUpdating],抓取位置并将后台线程延长10分钟。

Description: This basically asks the app for more time, when that extra time is about to expire, it calls [self.locationManager startUpdating], grabs the location and extends the background thread for 10 more minutes.

优点:


  • 一致

  • 可以像你想要的那样准确无误b
    想要它

缺点:


  • 有每隔十分钟或更短时间拨打一个电话,让应用程序在
    后台运行(即调用n不能大于10)

问题:
这对电池有什么影响?唤醒GPS并将其关闭会对电池造成更大伤害吗?我无法想象在后台运行一个简短的位置检查会耗尽电池......但话又说回来,我不知道是什么让GPS上电并获得可用的信号。

Questions: What effect does this have on the battery? Does waking up the GPS and shutting it off hurt the battery more? I couldn't imagine running a brief location check in the background would drain the battery that much... but then again, I don't know what goes into powering up the GPS and getting a usable signal.

startMonitoringForRegion(地理围栏):

简单地说,当您进入时,您的应用会被唤醒一个预定义的区域。这是他们的古怪,它是最新的,并且它的文档较少。我无法找到关于系统如何监视过境点的良好描述。据我所知,这是一个非常聪明的算法,或者他们不断地ping GPS,这会使其效率低于其他方法。

Simply put, your app gets woken up when you enter into a pre-defined region. This is the oddball of them, it is more recent and there is less documentation on it. I can't find a good description on how the "system monitors" the boundary crossing. For all I know it is some really smart algorithm, or they are constantly pinging the GPS which would make it less effective than the other methods for doing this.

优点:


  • 简单实施

  • 由系统管理,因此您不必发明自己的特设geo-fences只在触发边界时触发...没有不必要的数据只是为了换回电池而扔掉

  • 因此,对于这类事情应该是最好的,准确的,可管理的由系统

缺点:


  • 人们质疑其有效性

  • 是否或是否存在巨大冲突不是它对电池寿命有好处,或者b b $ b是否会耗尽电池寿命。

  • 系统如何监控它??

  • 基本上,不确定的行为。

  • People question its effectiveness
  • Huge conflicts on whether or not it is good for battery life or if it drains battery life terribly.
  • How is the system monitoring this!?
  • Basically, indeterminate behavior.

我想我的问题n归结为startMonitoringForRegion:在电池寿命,一致性和精确度方面,与后台测试用户位置的其他方法相比较。有没有人彻底测试过这个?或者在他们的应用程序中使用它并获得至少一些反馈?可能,就我的目的而言,权衡是在地理围栏和10分钟更新方法之间。 (同样考虑到Apple公开谈论的iOS7会有一些后台任务......这会改变这两种方法之间权衡的微积分吗?)有没有人知道这两者的比较方式?

I guess my question boils down to how does startMonitoringForRegion: compare to these other methods of testing user location in the background when it comes to battery life, consistency, and precision. Has anyone thoroughly tested this? Or used it in their app and gotten at least some feedback? Likely, for my purposes, the trade-off is between geo-fencing and the 10 minute update method. (Also given what Apple has publicly said about iOS7 there will be some background tasks... will this change the calculus for the trade-off between these two methods?) Does anyone have an idea of how these two compare?

非常感谢!期待看看我们是否可以深入了解如何比较这些方法。

Thanks so much! Looking forward to seeing if we can get to the bottom of how to compare these methods.

推荐答案

我一直在研究车辆使用GPS跟踪2年。学到了很多东西...根据我的经验,startMonitoringForRegion或Geo-fencing取决于单元格更改事件,didEnter或didExit事件在单元格/ wifi更改事件之前不会启动。所以它对电池消耗没有任何影响。但是它会进行额外的计算,这取决于当前监视的区域数量。即使Apple的Reminder应用程序也没有为基于位置的提醒提供良好的结果,因为它使用了地理围栏。

I've been working on vehicle tracking using GPS for 2 years. Learned a lot the hard way... In my experience startMonitoringForRegion or Geo-fencing depends upon cell change events, didEnter or didExit events doesn't fire up until there is a cell/wifi change event. So it doesn't make any difference w.r.t battery consumption. However it does extra computation which depends on how many regions currently are being monitored. Even Apple's Reminder app doesn't give good results for location based reminders because it uses geo-fencing.

另一种方法是在每分钟m分钟后启动GPS n分钟不错的选择,如果明智地完成,它不应该影响电池寿命。在高精度模式下,电池对GPS激活的确切影响是什么?例如,如果您使用kCLLocationAccuracyBest和distance-filter = 0启用GPS,您可以从字面上观察电池排水情况,很快您的设备也会开始变热。

The other approach starting GPS for n minutes after each m-minutes is good option, it should not affect the battery life, if done wisely. What exactly effect the battery is constant GPS activation in high precision mode. Like for instance If you enable GPS with kCLLocationAccuracyBest and distance-filter = 0, you can literally observe battery drainage and soon your device will also start getting hotter.

如果我是你,我会用kCLLocationAccuracyBest每10分钟激活一次GPS持续5秒(或者如果准确度不是那么多,可以使用kCLLocationAccuracyNearestTenMeters来减少电池使用量重要的)和距离过滤器= 5(米)。在这种情况下,电池消耗将是不明显的。您可以使用类似的设置来解决您的特定情况,并最终找出最适合您的设置。

If I was you, I would go for activating GPS after every 10 minutes for 5 sec with kCLLocationAccuracyBest (or may kCLLocationAccuracyNearestTenMeters to use less battery, if accuracy is not that much important) and distance-filter = 5 (meters). Battery consumption in this case will be unnoticeable. You can play around with similar settings which can address your specific case and finally find out what is best you.

BTW:iPhone使用AGPS,A-GPS还使用网络资源在信号较差的情况下定位和使用卫星。因此,当您执行startUpdatingLocation时,它还将使用附近的蜂窝塔信息。请参阅 http://en.wikipedia.org/wiki/Assisted_GPS

BTW: iPhone uses AGPS, A-GPS additionally uses network resources to locate and use the satellites in poor signal conditions. So, when you do startUpdatingLocation it will also use nearby cell tower information. see http://en.wikipedia.org/wiki/Assisted_GPS

这篇关于CLLocationManager geo-fencing / startMonitoringForRegion:与startMonitoringForSignificantLocationChanges:对比10分钟startUpdating调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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