Hi every one Here is my issue
I'm trying to set a timer so it let the user walk a bit before present a message in the future. I've look in most documented website but it won't work.
In console I get print timestamp every seconds
------------------------------
extension TrackHistoryTableViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let seconds = 300.0
if previousLocation == nil { previousLocation = locations.first
} else {
guard let newLocation = locations.last else { return }
if newLocation.speed > 0 {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
print("Too slow")
print(newLocation.timestamp)
}
if newLocation.speed < 1 {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
print("Too slow")
print(newLocation.timestamp)
}
} else if newLocation.speed >= 8.8 {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
print("too fast")
print(newLocation.timestamp)
}
print("too fast")
print(newLocation.timestamp)
}
} else {
locationManager?.startUpdatingLocation()
}