Reputation: 282
I am trying to implement geofire
into one of my firebase
cloud functions and can't understand why the query callbacks are not firing. The dashboard log continues to display nothing returned or nothing documented via console.log()
.
Any guidance would be appreciated..below is my code:
exports.test = functions.firestore.document('/x/{userId}').onWrite((change, context) => {
const userData = change.after.exists ? change.after.data() : null;
const geoPoint = userData.location;
const lat = geoPoint._latitude;
const long = geoPoint._longitude;
var geoFireRef = firebase.database().ref('geoLocations');
var geoFire = new GeoFire(geoFireRef);
const circle = geoFire.query({
center: [lat, long],
radius: 0.5
});
circle.on('key_entered', function(key, location, distance) {
console.log(key + " entered query at " + location + " (" + distance + " km from center)");
return;
});
circle.on('ready', function() {
console.log('ready');
return;
});
});
Upvotes: 2
Views: 241
Reputation: 282
There was nothing wrong with the code. I figured out the issue was found with the set rules that prevented the geofire query from executing in the first place.
Upvotes: 1