Reputation: 225
I'm trying to ping all users in a certain channel within a certain distance from the current user's location. The problem I am stuck on is my inability to satisfy both constraints. One or the other works by itself. With both, the message is sent to nobody somehow. Am I missing something here? Thanks in advance!
func findDriver(loc: CLLocationCoordinate2D) {
let driverQuery = PFInstallation.query()
driverQuery?.whereKey("channels", equalTo:"drivers")
let geoPoint = PFGeoPoint(latitude: loc.latitude, longitude: loc.longitude)
driverQuery?.whereKey("location", nearGeoPoint: geoPoint)
let push = PFPush()
push.setQuery(driverQuery)
push.setMessage("Looking for Drivers!")
push.sendPushInBackground()
}
Upvotes: 0
Views: 33
Reputation: 4107
Maybe try to do AND for query ?
here is the link: https://www.parse.com/questions/combining-or-queries
func findDriver(loc: CLLocationCoordinate2D) {
let driverQuery = PFInstallation.query()
driverQuery?.whereKey("channels", equalTo:"drivers")
let geoPoint = PFGeoPoint(latitude: loc.latitude, longitude: loc.longitude)
driverQuery?.whereKey("location", nearGeoPoint: geoPoint)
let comboQuery = PFQuery.query()
comboQuery?.whereKey("channels", matchesKey:"channels", inQuery:driverQuery)
comboQuery?.whereKey("location", matchesKey:"location", inQuery:geoPoint)
let push = PFPush()
push.setQuery(comboQuery)
push.setMessage("Looking for Drivers!")
push.sendPushInBackground()
}
Upvotes: 0