Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 向Firebase规则添加索引_Ios_Swift_Firebase_Firebase Realtime Database_Geofire - Fatal编程技术网

Ios 向Firebase规则添加索引

Ios 向Firebase规则添加索引,ios,swift,firebase,firebase-realtime-database,geofire,Ios,Swift,Firebase,Firebase Realtime Database,Geofire,我正在使用GeoFire根据用户的当前位置从Firebase查询数据。我得到: 使用未指定的索引。考虑添加“.Noxon”:“G”AT / TO 您的安全规则可提高性能 在控制台中。下面是我的查询代码: ref = Database.database().reference() let geoFire = GeoFire(firebaseRef: ref) let center = CLLocation(latitude:

我正在使用GeoFire根据用户的当前位置从Firebase查询数据。我得到:

使用未指定的索引。考虑添加“.Noxon”:“G”AT / TO 您的安全规则可提高性能

在控制台中。下面是我的查询代码:

            ref = Database.database().reference()
            let geoFire = GeoFire(firebaseRef: ref)

            let center = CLLocation(latitude: (userLocation.coordinate.latitude), longitude: (userLocation.coordinate.longitude))

            let circleQuery = geoFire?.query(at: center, withRadius: 1)

            circleQuery?.observe(.keyEntered, with: { key, location in

                guard let key = key else { return }

                geoFire?.getLocationForKey(key, withCallback: { (location, error) in

                    let myAnnotation: MKPointAnnotation = MKPointAnnotation()
                    myAnnotation.coordinate = CLLocationCoordinate2DMake((location?.coordinate.latitude)!, (location?.coordinate.longitude)!);
                    self.currentLocationMapView.addAnnotation(myAnnotation)      
                })


                self.ref.child("services").child(key).observeSingleEvent(of: .value, with: { (snapshot) in

                    let value = snapshot.value as? NSDictionary
                    let servicename = value?["name"] as? String ?? ""
                    let address = value?["address"] as? String ?? ""

                    self.nameArray.append(servicename)
                    self.addressArray.append(address)


                    if (self.nameArray.count > 0) {
                        self.customTableView.reloadData();     
                    }

                })

            }) 
“我的Firebase规则”选项卡具有以下设置

"rules": {
    ".read": true,
        ".write": "auth != null"
          }
无论我在哪里插入“.indexOn”:“g”,我都会出错,无法保存规则。有什么帮助吗?

您要了解的要点

你要去的地方

"rules": {
  ".read": true,
  ".write": "auth != null",
  ".indexOn": ["g"]
}