Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shorter time interval for location updates

My app is highly based on CLLocation timestamp. I found that CLLocationManager updates location in ~1s intervals. It's not enough for my app. Is it possible to configure CLLocationManager to update location in shorter intervals or should I look for other approach (timers + ask manually for location)?

locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.allowsBackgroundLocationUpdates = true
locationManager.distanceFilter = kCLDistanceFilterNone
if #available(iOS 11.0, *) {
    locationManager.showsBackgroundLocationIndicator = true
}
locationManager.startUpdatingLocation()

timer + requestLocation() doesn't work.

like image 253
Tomasz Pikć Avatar asked Mar 21 '26 13:03

Tomasz Pikć


1 Answers

You cannot change frequency of updates. But you probably don't need that. You can calculate phone position by using CMMotionManager framework and you can get the user location using CLLocationManager framework.

Use accelerometer to calculate device movement. From didAccelerate method you can get x, y and z of move, so by applying this to detected user location you can calculate new device position.

Hope this helps and good luck.

like image 153
Taras Chernyshenko Avatar answered Mar 24 '26 01:03

Taras Chernyshenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!