I want to retrieve data from a firebase database with geofire location query but its just trigring onGeoQueryReady instead of onKeyEntered.
I'm setting my location like this
user = auth.getCurrentUser().getUid();
GeoFire geoFire = new GeoFire(ref.child("businesLocation").child(Education).child(CoachingCenter));
geoFire.setLocation(user, new GeoLocation(latitude, longitude), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
}
});
}
});
and retriving data like this
GeoFire geoFire = new GeoFire(ref.child("businesLocation").child(Education).child(CoachingCenter));
GeoQuery geoQuery = geoFire.queryAtLocation((location), Raius);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
@Override
public void onKeyEntered(String key, GeoLocation location) {
getShoplist(key);
}
@Override
public void onKeyExited(String key) {
getShoplist(key);
}
@Override
public void onKeyMoved(String key, GeoLocation location) {
}
@Override
public void onGeoQueryReady() {
}
@Override
public void onGeoQueryError(DatabaseError error) {
}
});
This query is not getting the data.
Here is my database structure
Here are my firebase security rules
{"rules": {
".read": "auth != null",
".write": "auth != null"}}
Do I need to change the firebase security rules for using geofire?
Please help me out!
After changing my database security rules it starts working
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"geofire": {
".read": "true",
".indexOn": ["g"]
}
}
}
it starts fetching the data now.:)