Commit 3a2ed5dc by Sebastián Katzer

Fixes #732 loop between update and trigger

parent fd647138
......@@ -5,6 +5,7 @@ Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-lo
#### Version 0.8.3 (not yet released)
- New "quarter" intervall for iOS & Android
- Fixed #732 loop between update and trigger (Android)
- Fixed #710 crash due to >500 notifications (Android)
- Fixed crashing `get(ID)` if notification doesn't exist
......
......@@ -70,7 +70,7 @@ abstract public class AbstractTriggerReceiver extends BroadcastReceiver {
Builder builder = new Builder(options);
Notification notification = buildNotification(builder);
boolean updated = notification.isUpdate();
boolean updated = notification.isUpdate(false);
onTrigger(notification, updated);
}
......
......@@ -31,7 +31,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -121,7 +120,7 @@ public class Manager {
notification.getOptions().getDict(), updates);
try {
options.putOpt("updatedAt", new Date().getTime());
options.putOpt("updated", true);
} catch (JSONException ignore) {}
return schedule(options, receiver);
......
......@@ -138,16 +138,18 @@ public class Notification {
/**
* If the notification is an update.
*
* @param keepFlag
* Set to false to remove the flag from the option map
*/
protected boolean isUpdate () {
if (!options.getDict().has("updatedAt"))
return false;
protected boolean isUpdate (boolean keepFlag) {
boolean updated = options.getDict().optBoolean("updated", false);
long now = new Date().getTime();
long updatedAt = options.getDict().optLong("updatedAt", now);
if (!keepFlag) {
options.getDict().remove("updated");
}
return (now - updatedAt) < 1000;
return updated;
}
/**
......@@ -268,7 +270,7 @@ public class Notification {
}
json.remove("firstAt");
json.remove("updatedAt");
json.remove("updated");
json.remove("soundUri");
json.remove("iconUri");
......
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