Create the application where user can track the car on the map, same like OLA and Uber application do.
Track-Car makes it easy to add tracking functionalities to your iOS app!
Just download the project, drag and drop the “TrackCar” folder in your application.
Create the LocationService and implement in your view controller
class YourViewController: {
let locationService = LocationService()
}
Subscribe the PassthroughSubject subject which send the location at 1 second interval
cancelSubject = locationService.locationSubject
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { (completion) in
switch completion {
case .failure(let error):
....
case .finished:
break
}
}) { [weak self] (item) in
self?.updateCarLocation(model: item)
}
locationService.setupTimerPublisher()
And cancel the subscriber when it no longer needs to receive elements. For ie. cancelSubject.cancel()
func updateCarLocation(model: CarModel) {
self.locationService?.updateLocationOnMap(model: model, myAnnotation: myAnnotation, mapView: mapView)
}
Track-Car
is available under the MIT license, see the LICENSE file for more information.