简体   繁体   中英

GeoFire observeBlock are only called once in Swift project

This is my simplified code for GeoFire observing: The problem is that observeReady are only called once, on initial observation, however when new keys are entered, the observe function is working fine, but completion block is not getting called.

func startObserveNearbyPosts(location: CLLocation) {
        let geoFireQuery = geoFire?.query(at: location, withRadius: 100)

        geoFireQuery?.observe(.keyEntered, with: { (key, _) in
            print("Key entered")
        })

        geoFireQuery?.observeReady {
            print("Observe ready")
        }
    }

From the Geofire documentation :

Sometimes you want to know when the data for all the initial keys has been loaded from the server and the corresponding events for those keys have been fired.

So it looks like observeReadyWithBlock only gets called after the initial set of .keyEntered has been fired, not for subsequent updates (unless you change the query). Of course .keyEntered should get called for each key that enters the queried range.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM