iOS 6 AutoPause doesn't work

2019-02-15 13:48发布

I've follow the example of AutoPause from "Session 303 - Staying on track from Location Services" WWDC 2012

In the example you can see how AutoPause is enabled and there two methods which are called:

-(void) locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager
-(void) locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager

I've done the same example but these methods aren't never called. Who have tried the same?

2条回答
何必那么认真
2楼-- · 2019-02-15 13:57

I had the same problem and found you have to set the property pausesLocationUpdatesAutomatically to YES

查看更多
We Are One
3楼-- · 2019-02-15 13:58

I'm experimenting with that right now and here are my observations:

On iPhone 4, that is not working at all. Even if you set pausesLocationUpdatesAutomatically to YES it keeps pausesLocationUpdatesAutomatically as NO(0). No warnings, what kind of API design anti-pattern is this!

On iPhone 5 pausesLocationUpdatesAutomatically is YES (1) by default. And locationManagerDidPauseLocationUpdates is called. I'm having a bad luck having the locationManagerDidResumeLocationUpdates called. I'm also puzzled how this is going to be called if GPS is off? Will it be called once user reaches the next network cell? Even that is not my experience, it is not ever called.

So far, looks to me as one of the least consistent changes in iOS6. I might be going with just pausesLocationUpdatesAutomatically = NO for all scenarios and will hope that works ok on all models with iOS6.

[Update - 4-Mar-2013]. I looked through the Apple's presentation for location changes in iOS6 and they suggest to use the region changes monitoring to "un-pause" once you get region changes event. Though this is not suitable for my scenarios as user might go/run/drive for a kilometer or two until such an event happens.

查看更多
登录 后发表回答