CLLocationManager Update frequency

2019-08-02 08:58发布

I have configured locationManager as follows.

_locationManager = [[CLLocationManager alloc] init];
[_locationManager setDelegate:self];
[_locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[_locationManager setDistanceFilter:kCLDistanceFilterNone];

When the application runs, I get some updates from the delegate methods. And when I do not change the location, and the mobile is stationary for about 2 hrs, I receive about 10-12 updates in the first 10 mins, and then stop receiving updates.

What I understand is that desiredAccuracy is how long the device will keep trying more and more accurate methods to get the current location. So in my case, it takes about 10 mins to get the desired accuracy.

I want to confirm if this is true. Also is there a way where I can get regular location updates even if the device is not moving?

1条回答
倾城 Initia
2楼-- · 2019-08-02 09:16

Why would you expect the location to be updated if it hasn't changed?

If you want to periodically refresh your results, use an NSTimer you've created yourself.


When the device gets a location with a margin of error < desiredAccuracy, it will stop asking for more accurate results. If the device moves then it will start asking again, until it once again gets the location to the desired accuracy.

If you're specifying 10m for the accuracy then you're almost certainly going to be relying on GPS - cell towers and wifi aren't that accurate (usually).

To determine if the device has moved, it uses distance filter - by setting this to none you are asking it to be accurate to the nearest 10m all the time - this is probably going to be quite draining on the battery ;)

查看更多
登录 后发表回答