Ich hoffe, Sie können mir helfen, weil mein Gehirn vom Denken brennt: D. Ich möchte den Benutzer z.B. alle 100 Meter. Aber ich möchte die Aktualisierung des Standortdienstes nicht ändern. Es gibt einen einfachen Weg, aber mir geht es nicht gut. Ich denke, es gibt eine bessere Lösung. Was ich bisher (die Pseudo-Code ist!) Das in didUpdateLocation genannt wirdSwift Standorte: Feuer alle X Meter eine Benachrichtigung
//We want notify User but only 5 times during the movement
if distanceToReport < settedDistance {
//Store that first Notification is fired
if !firstNotificationFired {
self.notifyUser(report: report)
}
if firstNotificationFired && distanceToReport <= 400 {
//Store that second Notification is fired
self.notifyUser(report: report)
} else if secondNotificationFired && distanceToReport <= 300 {
//Store that third Notification is fired
} else if thirdNotificationFired && distanceToReport <= 200 {
//Store that fourth Notification is fired
} else if fourthNotifiationFired && distanceToReport <= 100 {
//Store that fifth Notification is fired
}
}
eine viel bessere und effiziente Art und Weise als dies dort ist? Oder gibt es irgendwelche mathematischen oder Algorithmen, die helfen können?
Danke bis jetzt.