Commit 3a2ed5dc authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Fixes #732 loop between update and trigger

parent fd647138
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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

+1 −1
Changes for src/android/notification/AbstractTriggerReceiver.java: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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);
    }
+1 −2
Changes for src/android/notification/Manager.java: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -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);
+10 −8
Changes for src/android/notification/Notification.java: 10 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -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");