swift - GFCircleQuery 不返回任何结果

标签 swift firebase firebase-realtime-database location geofire

我使用Geofire对于 iOS。我遇到了以下问题,我使用 Geofire 来获取当前用户旁边的卡和用户。对于卡片,结果是正确的,但对于用户,我没有得到任何结果,尽管 Firebase 数据库中的数据结构用于存储卡片和用户的位置是相同的。请告诉我如何解决这个问题?

我的结构数据

"cardLocation" : {
   "-KjLxK0q39JnT2MZEalB" : {
     ".priority" : "v17wefy8z",
     "g" : "v17wefy8z",
     "l" : [ *****, ****** ]
   },
   "-KjM7_5sPkoruwoTvRzR" : {
     ".priority" : "9q5c2ypf3",
     "g" : "9q5c2ypf3",
     "l" : [ ******, -****** ]
   },
   "-KjNDq8nQ2Ffjr9M_1a9" : {
     ".priority" : "9q59x2vc6",
     "g" : "9q59x2vc6",
     "l" : [ *******, -***** ]
   }
 },

"userLocations" : {
   "1Cix149ThIOG1ULPVjyy0LyTxbe2" : {
     ".priority" : "87zc0d2j5",
     "g" : "87zc0d2j5",
     "l" : [ ******, -**** ]
   },

最佳答案

我没有通过向其模型添加附加属性来正确使用 geofire。现在我只向其中添加 CLLocation,它对我有用。

   let geofireRef = Database.database().reference().child(MainGateways.cardLocation.rawValue)
                guard let geoFire = GeoFire(firebaseRef: geofireRef) else { return }
                dispatchGroup.enter()
                geoFire.setLocation(cardLocation, forKey: cardModelRef.key) { (error) in
                    commonError = error
                    dispatchGroup.leave()
                }

关于swift - GFCircleQuery 不返回任何结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43805559/

相关文章:

java - Java中的自定义下标

javascript - 设置范围后启动 svg 动画 - angularjs - svg

android - 为什么我不能使用模型类在数据库中设置特定子项的值?

Swift - 如何允许人们设置自己的 Firebase 后端?

android - 如何使用 firebase-server 在 android 下模拟 firebase 云消息传递

ios - completionHandler 不能在 Xcode 的单元测试中执行,例如。异步 api - CLGeocoder 的 reverseGeocodeLocation

ios - 如何使用 Realm 通知

swift - WKWebView 在 iOS 9.0 中无法快速显示网站

node.js - 如何用nodejs进行动态调度?

android - 错误 :(15, 55) 找不到错误 : cannot access zza class file for com. google.android.gms.common.internal.safeparcel.zza