使用geoFire和Swift 4按位置提取帖子

时间:2019-02-05 01:06:47

标签: swift firebase geofire

我正在尝试按位置获取帖子,并使用firebase和geofire用帖子填充我的收藏夹视图。但是目前我还没有输入键值。我也在物理设备上尝试过,但没有成功。

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    let userLocation:CLLocation = locations[0]

    guard let uid = Auth.auth().currentUser?.uid else { return }

    let rootRef = Database.database().reference()
    let geoRef = GeoFire(firebaseRef: rootRef.child("posts"))

    let query = geoRef.query(at: userLocation, withRadius: 1000)

    query.observe(.keyEntered, with: { key, location in
        print("Key: " + key + "entered the search radius.")
    })
}

0 个答案:

没有答案