/** * Sets the message that will be shown in the notification. This will overwrite any data specified * in {@link #setData(JSONObject)}. */ public void setMessage(String message) { JSONObject data = new JSONObject(); try { data.put(KEY_DATA_MESSAGE, message); } catch (JSONException e) { PLog.e(TAG, "JSONException in setMessage", e); } setData(data); }
/** * A helper method to concisely send a push to a query. This method is equivalent to ParsePush * push = new ParsePush(); push.setData(data); push.setQuery(query); push.sendInBackground(); * * @param data The entire data of the push message. See the push guide for more details on the data * format. * @param query A ParseInstallation query which specifies the recipients of a push. * @return A task that is resolved when the data is sent. */ public static Task<Void> sendDataInBackground(JSONObject data, ParseQuery<ParseInstallation> query) { ParsePush push = new ParsePush(); push.setQuery(query); push.setData(data); return push.sendInBackground(); }
@Test public void testSetData() throws Exception { ParsePush push = new ParsePush(); JSONObject data = new JSONObject(); data.put("key", "value"); data.put("keyAgain", "valueAgain"); push.setData(data); // Right now it is hard for us to test a builder, so we build a state to test the builder is // set correctly ParsePush.State state = push.builder.build(); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); }