I am trying to pull down all my location results from Firebase with the help of Geofire. Unfortunately I am unable to do so. I have read through all the documentation with no luck as to why I cannot get it to work.
I establish my geoFireRef...
var geoFire: GeoFire!
var geoFireRef: DatabaseReference!
geoFireRef = Database.database().reference()
geoFire = GeoFire(firebaseRef: geoFireRef)
I set my location in Firebase with the build in method...
geoFire.setLocation(location, forKey: "\(myKey)")
But when I try to pull the information down from the database I am unable to do so.
func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated:
Bool) {
let loc = CLLocation(latitude: mapView.centerCoordinate.latitude, longitude: mapView.centerCoordinate.longitude)
showGamesOnMap(location: loc)
}
func showGamesOnMap(location: CLLocation) {
let circleQuery = geoFire.query(at: location, withRadius: 2.5)
//ABLE TO PRINT HERE
Swift.print("Starting Query")
circleQuery.observe(.keyEntered, with: { (key: String?, location: CLLocation?) in
//UNABLE TO PRINT HERE
Swift.print("Key '\(key!)' entered the search are and is at location '\(location!)'")
})
}
Here are my rules that I have established in my database.
{
"rules": {
".read": true,
".write": true,
".indexOn": ["g"]
}
}
I have been debugging for over two days with no luck what so ever. Thanks in advance.