Commit bb4070dd by Brandon Evans

Always restore Android notifications with a minimum date of now

This change prevents missing a notification that was scheduled to fire when the
device was off by re-registering it for right now. This matches the behaviour on
iOS.
parent 7ae2981b
...@@ -54,6 +54,16 @@ public class Restore extends BroadcastReceiver { ...@@ -54,6 +54,16 @@ public class Restore extends BroadcastReceiver {
for (String alarmId : alarmIds) { for (String alarmId : alarmIds) {
try { try {
JSONArray args = new JSONArray(alarms.getString(alarmId, "")); JSONArray args = new JSONArray(alarms.getString(alarmId, ""));
/* If this notification was registered for a time when the
* device was off then change the date to now to ensure that no
* notifications are missed
*/
Date now = new Date();
if (now.after(new Date(args.optLong("date") * 1000))) {
args.put("date", (now.getTime() / 1000));
}
Options options = new Options(context).parse(args.getJSONObject(0)); Options options = new Options(context).parse(args.getJSONObject(0));
LocalNotification.add(options); LocalNotification.add(options);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment