iOS多任务跟踪GPS位置 [英] iOS Multi-Tasking Track GPS Location

查看:98
本文介绍了iOS多任务跟踪GPS位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试着用这个方法来测试你的位置是否可以通过GPS跟踪你的位置。内置的应用程序地图,但无济于事。



如果可以的话,如果您可以引用我一些示例代码,文档或教程!



(如果这是重复的,请让我知道,我会删除它)

解决方案

这是可能的 - 请参阅此文档用于一般多任务处理和位置感知编程指南中的在后台获取位置事件部分。当然,所有这些都讨论了iOS设备可以获得您的位置的各种方式(手机塔三角测量,Skyhook式wifi网络观测和GPS),而不是独家的GPS。

简而言之,通过阅读这些文档:将UIBackgroundModes键添加到您的info.plist中,这是一个数组,并将值'location'放入其中。即使在后台,您也会收到CLLocationManager更新。



然而,如果您想要更好地使用电池,那么最好使用startMonitoringSignificantLocationChanges方法一个CLLocationManager。那么即使在后台应用程序中,即使在后台应用程序中,您也可以获得适当的位置更新。文件的其他部分指出,重大变化是从一个单元塔到另一个单元塔的任何变化。

I was just wondering if it was possible to make an iOS app that would track your location via GPS while it was in the background.

I tried this with the built-in app "Maps", but to no avail.

If this is possible, it would be great if you could refer me to some sample code, documentations, or tutorials!

(if this is a duplicate, please let me know and I will remove it)

解决方案

This is possible — see this document for multitasking in general and this section of the Location Awareness Programming Guide for "Getting Location Events in the Background". Of course, all these talk about all of the various ways an iOS device can get your location (cell tower triangulation, Skyhook-style wifi network observation and GPS), not exclusive GPS.

In short, from reading those docs: add the UIBackgroundModes key into your info.plist, which is an array, and put the value 'location' into it. You'll then receive CLLocationManager updates even when in the background.

However, if you want to be nice to the battery then you're better off using the startMonitoringSignificantLocationChanges method on a CLLocationManager. Then you get suitably significant location updates even when in the background without being a full on background app. Other parts of the documentation state that a significant change is any change from one cell tower to another.

这篇关于iOS多任务跟踪GPS位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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