I have an iOS app that has employees that need to be notified of pickups nearby. I want to perform a Firestore query and filter the radius of documents returned. I came up with this solution
but @Frank van Puffelen pointed out my question may be an x y problem and he was right!
I want is to listen to firebase Firestore for documents added then return results near my location. My documents have geopoint and geohash data. Is there a way to write a query in swift that has a listener attached and filters for documents within 100 miles? This is my current query in swift:
extension Firestore {
var pickups: Query {
return collection("pickups").whereField("employeeUID", isEqualTo: "none").order(by:
"date")
}
}
func getPickups() {
listener = db.pickups.addSnapshotListener({ (snap, error) in
guard let documents = snap?.documents else { return }
for document in documents {
let data = document.data()
let newPickup = PickUps(data: data)
self.pickups.append(newPickup)
}
})
}
Any ideas about a query would be greatly appreciated - Thank you!