intuit / LocationManager

Easily get the device's current location on iOS.
MIT License
2.56k stars 387 forks source link

Define time interval when subscribing to continuous location updates in background #109

Closed prgorasiya closed 6 years ago

prgorasiya commented 6 years ago

I would like to know whether I can define an interval at which I can get continuous location updates in background mode. Currently, that time interval is about 15 secs but I would like to make it 5 secs.

Here is my code

requestID = backgroundLocationManager.subscribeToLocationUpdates(withDesiredAccuracy: .room) { (location, accuracy, status) in
            if status == INTULocationStatus.success{
                print(location as Any)
            }
}

Any help with that?

Thanks

lwdupont commented 6 years ago

No there is no way to do that now. Right now you'll get a callback when the location changes.

Why would you want to get the location at a fixed interval of time?

prgorasiya commented 6 years ago

Basically my app's purpose is based on sending user's location every 10 seconds to my backend. I saw that you have included this task in next release, may I know when will you be releasing that version and how to use this feature? Thanks

lwdupont commented 6 years ago

Ah, got Ya. It would be better for you to do something like this in your code:

  1. Subscribe to location changes with this library
  2. Keep the last location that it sent you
  3. Send that 'currentLocation' every 10 seconds.
prgorasiya commented 6 years ago

Yeah I have already done something like that but it would be nice to have this feature within the library itself to conserve battery and get location efficiently at every defined interval.