开发者

iPhone Brainstorm - CLLocation in Background - Polling every 15 minutes

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.

At the moment I:

  1. Start / Restart the location manager with accur开发者_开发百科acy 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.


If you're not targetting iOS3, consider using the 'significant change' API, it's supposed to be the most efficient for this kind of scenario.


Why not register the app for significant location change and just use that? Plenty of apps do (including some of mine) and it's quite battery-friendly. In fact, NOTHING HAPPENS unless the phone does a cell tower hand-off. If the phone sits somewhere for hours, there's literally NO battery impact. In your approach the whole CL framework and the GPS hardware has to fire up every 15 minutes.


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

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.

Hope this helps anyone in the future. Thanks James

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜