iPhone头脑风暴 - 背景中的CLLocation - 每15分钟轮询一次 [英] iPhone Brainstorm - CLLocation in Background - Polling every 15 minutes

查看:126
本文介绍了iPhone头脑风暴 - 背景中的CLLocation - 每15分钟轮询一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是该方案。我需要有一个应用程序,无论是在后台还是前台,每15分钟轮询一次具有用户位置的Web服务。

Here is the scenario. I need to have an application which polls a web service with the users location every 15 minutes whether in background / foreground.

目前我:


  1. 启动/重启位置管理器,精度最高,距离过滤器无。

  2. 等待达到理想的准确度。

  3. 商店阅读

  4. setDesiredAccuracy为:kCLLocationAccuracyThreeKilometers

  5. setDistanceFilter为:1000

  6. 设置performSelector:@selector(getLocation)withObject:nil afterDelay:900

  7. 从步骤1重新开始。

  1. Start / Restart the location manager with accuracy highest and distance filter none.
  2. Wait to get within desired accurancy.
  3. Store reading
  4. setDesiredAccuracy to be: "kCLLocationAccuracyThreeKilometers"
  5. setDistanceFilter to be: 1000
  6. Set a performSelector:@selector(getLocation) withObject:nil afterDelay:900
  7. Start again from step 1.

我想让这个节省电池的方法尽可能多,并希望看到哪些'堆叠器能够想到上面的选项以及你们是否还有其他任何建议。

I want to make this the most battery saving method possible and would like to see what fellow 'stackers think of the option above and if you guys have any other suggestions.

谢谢
詹姆斯。

Thanks James.

推荐答案

最后,我得到了一个应用程序,每15分钟在performSelector上启动/停止位置管理器:WithDelay。

In the end I got the application to start / stop the location manager every 15 minutes on a performSelector: WithDelay.

基本上当CLLocationManager提供所需精度的读数时,我降低了CLLocation以显示更改然后将应用程序设置为在15分钟后再读取一次,将准确性更改为其中一个最高设置和重复。

Basically when the CLLocationManager gave a reading within the desired accuracy I lowered the CLLocation to significate changes then set the application to take another reading 15 minutes later, changed the accuracy to one of the highest settings and repeated.

希望这有助于将来的任何人。
谢谢
James

Hope this helps anyone in the future. Thanks James

这篇关于iPhone头脑风暴 - 背景中的CLLocation - 每15分钟轮询一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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