2016-04-21 169 views
0

我想在距離當前用戶位置一定距離內的某個通道中ping所有用戶。我遇到的問題是我無法滿足這兩個限制。其中一個或另一個獨立工作。在這兩種情況下,消息都以某種方式發送給任何人。我在這裏錯過了什麼嗎?提前致謝!使用解析IOS推送通知

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

} 

回答

0

也許試着做和查詢?

這裏是鏈接: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() 

}