iPhone GPS - 电池消耗极快

时间:2023-03-22
本文介绍了iPhone GPS - 电池消耗极快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我们正在开发一个使用大量 GPS 的应用,我们无法优化电池寿命.

We are developing an app that has heavy GPS usage, and we are unable to optimize the battery life.

即使设备没有移动,也会有严重的电池消耗,根据代码,这种情况不应该发生.

Even when the device is not moved, there is significant battery drainage that, according to the code, should not happen.

代码如下:

locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = 100;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];

理想情况下,我们希望每 20 分钟触发一次 GPS(如果没有位置变化,则节省电池)或每 5 分钟触发一次位置变化.根据我的开发人员的说法,这是无法做到的

以前我们使用的是 kCLLocationAccuracyBest,它消耗电池的速度非常快,现在我们使用的是 kCLLocationAccuracyHundredMeters.

Previously we were using kCLLocationAccuracyBest, which was consuming battery very fast and now we are using kCLLocationAccuracyHundredMeters.

startUpdatingLocation - 是获取 GPS 坐标.还有另一个调用 startMonitoringSignificantLocationChanges 来获取 AGPS 坐标,我相信只要蜂窝塔发生变化就会返回坐标,因此会非常快地消耗电池.

startUpdatingLocation - is to get the GPS coordinates. There is another call startMonitoringSignificantLocationChanges which is to get AGPS coordinates which I believe returns the coordinates whenever cell tower will change, and hence consumes battery really fast.

distanceFilter - 在生成更新事件之前,设备必须横向移动的最小距离(以米为单位).根据距离过滤器,我们从设备获取 GPS 定位,然后将更新后的 GPS 坐标发送到服务器.

distanceFilter - The minimum distance (measured in meters) a device must move laterally before an update event is generated. On the basis of distance filter we get the GPS fix from the device and then we send the updated GPS coordinates to the server.

我们将不胜感激任何帮助谢谢!

推荐答案

还有另一个调用 startMonitoringSignificantLocationChanges是获取 AGPS 坐标,我相信它会返回坐标每当手机信号塔发生变化时,因此会真正消耗电池快.

There is another call startMonitoringSignificantLocationChanges which is to get AGPS coordinates which I believe returns the coordinates whenever cell tower will change, and hence consumes battery really fast.

这正是它的作用,但你会草率地得出关于所需功率的结论.GPS 接收器和 WiFi 收发器可用于帮助确定位置,但它们是额外的设备,必须通电才能使用.但是像 iPhone 这样的手机无论如何都需要与最近的手机信号塔保持联系才能接听电话,因此使用手机信号塔作为位置信息的来源在电力方面应该是非常有效的.以下是 CLLocationManager 参考页谈到-startMonitoringSignificantLocationChanges:

That's exactly what it does, but you're jumping to conclusions about the power required for that. The GPS receiver and WiFi transceiver can be used to help determine location, but they're extra devices that have to be powered to be useful. But mobile phones like the iPhone need to keep in touch with the nearest cell tower anyway in order to receive phone calls, so using cell towers as a source of location information should be very efficient with respect to power. Here's what the CLLocationManager reference page says about -startMonitoringSignificantLocationChanges:

此接口仅在检测到对设备的相关蜂窝塔,导致更新频率降低并显着降低功耗.

它还将该服务描述为提供极大的节能",因此它似乎是您描述的工作的正确工具.当然,如果您同时使用标准位置更新机制,您将看不到节能效果,因此请确保您没有同时使用这两种机制.

It also describes the service as providing "tremendous power savings," so it seems the right tool for the job you describe. Of course, if you're also using the standard location updating mechanism at the same time you won't see that power savings, so make sure you're not using both.

理想情况下,我们希望每 20 分钟触发一次 GPS(如果没有位置更改然后节省电池)或每 5 分钟(如果有)位置变化.根据我的开发人员的说法,这是无法做到的

Ideally we want to trigger GPS every 20 minutes (if there is no location change then save battery) OR every 5 minutes if there is location change. According to my developer this cannot be done

这听起来像是有某种误解.如果这是您想要的,您当然可以每 20 分钟启动一次 GPS 以进行修复,尽管您不能从后台执行此操作.即使应用程序在后台运行,重要的位置更改服务也会通知您的应用程序,因此您的开发人员可能正在谈论后台更新.

It sounds like there's some sort of misunderstanding here. You can certainly fire up the GPS every 20 minutes to get a fix if that's what you want, although you can't do that from the background. The significant location change service will notify your app even if it's running in the background, so perhaps your developer is talking about background updates.

这篇关于iPhone GPS - 电池消耗极快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:在 UIWebView 中启用 Cookie 下一篇:MapKit 中的 MapTypeStyle

相关文章