开发者

iPhone Core Location startMonitoringSignificantLocationChanges

I need to know when the user approaches a certain location.

On the iPhone 4 I'm using startMonitoringForRegion:desiredAccuracy: but this is not supported on the 3GS (which I want to support), so in this case I'm forced to use startMonitoringSignificantLocationChanges.

开发者_如何学JAVA

The thing is, startMonitoringSignificantLocationChanges causes the delegate to be called (and the app to be launched into the background if it is not) for every significant location change, even if it is totally unrelated to my needs.

It is easy for me to detect whether the delegate call is relevant for me, but I'm wondering about another thing: If I am launched into the background and then I detect that the call is not relevant, should I stay quietly in the background, or should I abort the app somehow and remove myself from the background until next time?


If you don't need to do anything with a location update, just return from the method call, and stay idle in the background. Don't try to abort the app, that will just cause unnecessary reloading (using battery) of your app next time you get a significant location change. The OS will terminate background app(s) if and when it decides it needs the memory space.


I would think that in your callback to the AppDelegate, if you determine the call is not needed, you just return; out and be done. The callback on location change would be called, but unless you decide to stop monitoring, the location monitoring will continue. The app is not brought into the foreground, just method calls from inside the AppDelegate.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜