You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sending scheduled push notifications is not currently supported by the Android SDK. Take a look at the [REST API]({{ site.baseUrl }}/rest/guide/#scheduling-pushes), [JavaScript SDK]({{ site.baseUrl }}/js/guide/#scheduling-pushes) or the push console on your Parse Dashboard.
322
+
You can schedule a push in advance by specifying a push time with `ParsePush.setPushTime(long)`. For example, if a user schedules a game reminder for a game tomorrow at noon UTC, you can schedule the push notification by sending:
323
+
324
+
```java
325
+
long tomorrowTime =...; // in seconds
326
+
327
+
// Send push notification with expiration interval
328
+
ParsePush push =newParsePush();
329
+
push.setPushTime(tomorrowTime);
330
+
push.setMessage("You previously created a reminder for the game today");
331
+
push.sendPushInBackground();
332
+
```
333
+
334
+
If you also specify an expiration interval, it will be calculated from the scheduled push time, not from the time the push is submitted. This means a push scheduled to be sent in a week with an expiration interval of a day will expire 8 days after the request is sent.
335
+
336
+
The scheduled time cannot be in the past, and can be up to two weeks in the future.
Copy file name to clipboardExpand all lines: _includes/android/queries.md
+36-1Lines changed: 36 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -311,6 +311,8 @@ You can query from the local datastore using exactly the same kinds of queries y
311
311
312
312
## Caching Queries
313
313
314
+
### With Local Datastore enabled
315
+
314
316
It's often useful to cache the result of a query on a device. This lets you show data when the user's device is offline, or when the app has just started and network requests have not yet had time to complete. The easiest way to do this is with the local datastore. When you pin objects, you can attach a label to the pin, which lets you manage a group of objects together. For example, to cache the results of the query above, you can call `pinAllInBackground` and give it a label.
Now when you do any query with `fromLocalDatastore`, these objects will be included in the results if they still match the query.
345
+
Now when you do any query with `fromLocalDatastore`, these objects will be included in the results if they still match the query. `ParseQuery` lets you choose whether to query the network (`fromNetwork`) or the local datastore (`fromLocalDatastore` or `fromPin(label)` to query just a subset). It is also possible to chain both requests, or execute them in parallel.
346
+
347
+
For instance, to query the cache first and then the network,
if (error instanceofParseException&& ((ParseException) error).getCode() ==ParseException.CACHE_MISS) {
368
+
// No results from cache. Let's query the network.
369
+
return query.fromNetwork().findInBackground();
370
+
}
371
+
return task;
372
+
}).continueWithTask((task) -> {
373
+
// Update UI with results ...
374
+
return task;
375
+
}, Task.UI_EXECUTOR);
376
+
```
377
+
378
+
### Without Local Datastore
344
379
345
380
If you aren't using the local datastore, you can use the per-query cache for `ParseQuery` instead. The default query behavior doesn't use the cache, but you can enable caching with `setCachePolicy`. For example, to try the network and then fall back to cached data if the network is not available:
0 commit comments