我正在尝试从iOS应用程序中使用Geofire。但是我在规则定义上失败了。
这是我的数据集的样子:
offers:{
user1:{
name : "Steph",
position : {
g:"xxxx",
l: {
0: 48.8795522,
1: 2.3568256
}
}
},
user2:{
name:"John",
position:{
g:"yyyy",
l: {
0: 48.8795528,
1: 2.3568256
}
}
}
}在我的Swift Code中,我使用了以下内容:
let geoRef = Firebase(url: appDelegate.fireBaseUrl + "/offers" )
let geoFire = GeoFire(firebaseRef: geoRef)
let center = CLLocation(latitude: 48.8795528, longitude:2.3568256)
let myQuery = geoFire.queryAtLocation(center, withRadius: 0.6)我把观察者设置成这样:
_ = myQuery.observeEventType(GFEventTypeKeyEntered, withBlock: { (key: String!, position: CLLocation!) in
print("Key '\(key)' entered")
})
_ = myQuery.observeEventType(GFEventTypeKeyMoved, withBlock: { (key: String!, position: CLLocation!) in
print("Key '\(key)' moved")
})
_ = myQuery.observeEventType(GFEventTypeKeyExited, withBlock: { (key: String!, position: CLLocation!) in
print("Key '\(key)' exited")
})我使用GeoFire方法为用户设置位置,如下所示:
geoFire.setLocation(CLLocation(latitude: myAdresse.Latitude, longitude: myAdresse.Longitude), forKey: "position")但我得到了这样的信息
使用未指定索引的Firebase。考虑在您的安全规则中添加".indexOn":"g“at /offers以获得更好的性能
我尝试了几种规则的组合。
{
"rules": {
"offers":{
".read": true,
".write": true,
"$users": {
"position":{
".indexOn":"g"
}
}
}
}
}我必须检查我的架构吗?还是我错过了什么?有什么帮助吗?
发布于 2015-12-10 08:09:31
我认为你在寻找:
{
"rules": {
"offers":{
".read": true,
".write": true,
"$users": {
".indexOn":"position/g"
}
}
}
}https://stackoverflow.com/questions/34190678
复制相似问题