简体   繁体   中英

IOS Push Notifications using Parse

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()

}

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()

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM