iOS4下如何避免过度使用电池?
当用户按下主页按钮时,我使用“位置”UIBackgroundMode 接收 GPS 后台更新。因此,如果应用程序在后台模式过夜,第二天早上电池就会一直没电。我已告诉 locationManager 停止更新位置,但没有效果。
我知道苹果不希望开发人员使用退出 - 事实上,除了将其带到后台之外,它似乎对应用程序没有什么影响 - 但如果用户不结束,我不能承受电池耗尽的后果该应用程序。
有什么建议吗?
I am using the 'location' UIBackgroundMode to receive GPS background updates when the user presses the Home button. As a result, if the app is left in background mode overnight, the battery is consistently dead the next morning. I have told the locationManager to stopUpdatingLocation, but to no effect.
I understand Apple doesn't want developers to use exit - in fact it seems to have little effect on the app other than to take it to the background - but I can't afford to have the battery die if the user doesn't end the app.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以注册一个本地通知,通知用户应该打开应用程序以停止位置跟踪?当然这不是很优雅,苹果似乎应该允许开发者在指定的时间内注册位置更新,也许你可以为此提交一个功能请求。我认为 Loopt 会监控 24 小时然后退出,也许你可以研究一下他们是如何让它在 24 小时后停止的。我希望我能提供更多帮助,但我根本没有搞乱位置框架。
Maybe you could register for a local notification that informs the user they should open the app to stop location tracking? It's not very elegant of course, it seems Apple should allow the developer to register for location updates for a specified length of time, maybe you could submit a feature request for that. I think Loopt monitors for 24 hours and then quits, maybe you could research into how they made it stop after 24 hours. I wish I could help more but I haven't messed with the location framework at all.
您可以使用计时器和/或后台任务,该任务将在一定的空闲时间后运行时间,然后尝试关闭 GPS。因此,您仍然可以在应用程序的后台进行位置跟踪,但 10-20 分钟后,它会关闭。
You could use a timer and/or background task, which would run after a set amount of idle time, and try to turn off the GPS then. So you can still have location tracking in the background of your app, but after 10-20 minutes, it turns off.