2016-04-21 124 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() 

}