This is a simple Swift class to provide all the configurations that you need to get background locations.
It's compatible with the latest Swift syntax if you're using any Swift version prior to 2.0.
Clone the project and execute in your simulator.
First add BackgroundTasks.swift and Tracker.swift to your project.
Instantiate the class:
let tracker = LocationController()
To start the service, configure distanceFilter property. Distance filter is the minimum distance (measured in meters) a device must move horizontally before an update event is generated.:
tracker.trackingDistance = 100.0
Set the timer to stop the tracker to save battery (seconds):
tracker.updateLocationTimer = 10.0
Set the timer to restart the manager to save battery (seconds):
tracker.restartTimer = 5.0
Set the timer to stop the tracker to save battery (seconds):
tracker.saveBatteryTimer = 5.0
Set the timer to stop the tracker to save battery (seconds):
tracker.startLocationTracking()
Don't forget to add the following lines in your plist file:
I encourage you to contribute to this repository.
Swift 2.0 (Xcode 7.3)