I want to trigger a notification everytime the current city changes based on didUpdateLocations
:
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let lastLocation = locations.last!
updateLocation(location: lastLocation)
}
So here I would compare if the city has changed and send a push notification based on that. How could I do this?
func updateLocation(location: CLLocation) {
fetchCityAndCountry(from: location) { city, country, error in
guard let city = city, let country = country, error == nil else { return }
self.locationLabel.text = city + ", " + country
if(city !== previousCity){
//Send push notification
}
}
}
I know I can trigger it based on location with a range but that's not specific enough for me.