2015-12-07 51 views
0

我試圖從設備本身發送地理圍欄通知。這是我的代碼。解析GeoPoint查詢不適用於Android SDK中的PushQuery

ParseQuery pushQuery = ParseInstallation.getQuery(); 
pushQuery.whereNear("currentLoc", parseGeoPoint); 

ParsePush push = new ParsePush(); 
push.setQuery(pushQuery); // Set our Installation query 
push.setMessage("geo push"); 
push.sendInBackground(); 

我從服務中添加了currentLoc和testText屬性,它在解析控制檯中顯示出來。代碼如下。現在

ParseInstallation installation = ParseInstallation.getCurrentInstallation(); 
installation.put("currentLoc", parseGeoPoint); 
installation.put("testText", "text"); 
installation.saveInBackground(); 

,如果我在查詢中使用pushQuery.whereEqualTo("testText", "texto");代替pushQuery.whereNear("currentLoc", parseGeoPoint);,通知被觸發。

但隨着whereWithinwhereNear查詢中使用時,它失敗並解析推控制檯會產生以下錯誤

ERROR: 
Unable to execute query: error processing query:  ns=appdata1109.app_ded5349f-37a1-4227-a4cc-62eccd9f8a07:_Installation limit=0 skip=0 Tree: GEONEAR field=currentLoc maxdist=1.79769e+308 isNearSphere=1 Sort: {} Proj: {} planner returned error: unable to find index for $geoNear query 

回答

0

做這樣使用whereWithinMiles

沒有必要額外場locationinstallation您可以使用 類的內部查詢和獲取位置User

// Find users near a given location 
ParseQuery userQuery = ParseUser.getQuery(); 
userQuery.whereWithinMiles("location", stadiumLocation, 1.0) //1.0 is radius in miles 

// Find devices associated with these users 
ParseQuery pushQuery = ParseInstallation.getQuery(); 
pushQuery.whereMatchesQuery("user", userQuery); 

// Send push notification to query 
ParsePush push = new ParsePush(); 
push.setQuery(pushQuery); // Set our Installation query 
push.setMessage("Free hotdogs at the Parse concession stand!"); 
push.sendInBackground();