Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting continous updates with fixed min time intervals/min distance #248

Closed
yogendragirase55 opened this issue Feb 8, 2019 · 1 comment
Assignees
Milestone

Comments

@yogendragirase55
Copy link

Hi Team

I need to get continue location for every 5 min and change 100 meter around last location.

So how can I get continue location every 5 min. please help me which method I can use and set timer 5 min.

@yogendragirase55 yogendragirase55 changed the title Location update continue Location update continue every 5 min Feb 8, 2019
@malcommac
Copy link
Owner

malcommac commented Sep 14, 2019

Hi,
Since 4.1.0 I've added the dataFrequency property inside the LocationRequest object. It's an enum:

// Data frequency to receive events
 enum DataFrequency {
  case asAvailable
  case fixed(minInterval: TimeInterval?, minDistance: CLLocationDistance?)
}

By default value for a new LocationRequest is asAvailable which means "no filters on frequency data. You can also set it to fixed` by specifying one or both the constraints (by minimum time and minimum distance, expressed in meters).

This is an example of the code.

let request = LocationManager.shared.locateFromGPS(.continous, accuracy: .city) { data in
            switch data {
            case .failure(let error):
                print("Location error: \(error)")
            case .success(let location):
                print("New Location: \(location)")
            }
        }
request.dataFrequency = .fixed(minInterval: 40, minDistance: 100) // minimum 40 seconds & 100 meters since the last update. 

Thanks for your suggestion.

@malcommac malcommac changed the title Location update continue every 5 min Getting continous updates with fixed min time intervals/min distance Sep 14, 2019
@malcommac malcommac self-assigned this Sep 14, 2019
@malcommac malcommac added this to the 4.1.0 milestone Sep 14, 2019
abakhtin added a commit to abakhtin/SwiftLocation that referenced this issue Sep 20, 2019
* commit 'e1eb681a94ba338bc92c4b529369c4318797186f':
  Added swift-package tools to 5.x
  Fixed never executed statment
  Updated podspec
  Bump to 4.1.0
  malcommac#248 Added documentation for dataFrequency
  malcommac#248 Added dataFrequency filter inside the LocationRequest object
  malcommac#252 Parsing of the place_id for OpenStreetMap in Place object (place_id)
  malcommac#261 Moved sources to Sources/SwiftLocation subdirectory to be compatible with Swift Package Manager
  malcommac#262 Added rawData property to get the raw JSON parsed from Place when using Google/OS services. Parsed place_id of Google Maps in identifier property.
  malcommac#263 GeocoderRequest.Options init() is now public

# Conflicts:
#	SwiftLocation.xcodeproj/project.pbxproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants