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

Fix getIds returns none existing notifications

parent 829501a9
Loading
Loading
Loading
Loading
+5 −5
Changes for src/android/ClickActivity.java: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -44,13 +44,13 @@ public class ClickActivity extends de.appplant.cordova.plugin.notification.Click
    public void onClick(Notification notification) {
        LocalNotification.fireEvent("click", notification);

        if (!notification.getOptions().isOngoing()) {
            String event = notification.isRepeating() ? "clear" : "cancel";
        super.onClick(notification);

            LocalNotification.fireEvent(event, notification);
        }
        if (notification.getOptions().isOngoing())
            return;

        super.onClick(notification);
        String event = notification.isRepeating() ? "clear" : "cancel";
        LocalNotification.fireEvent(event, notification);
    }

    /**
+6 −0
Changes for src/android/notification/ClickActivity.java: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,12 @@ public class ClickActivity extends AbstractClickActivity {
    @Override
    public void onClick(Notification notification) {
        launchApp();

        if (notification.isRepeating()) {
            notification.clear();
        } else {
            notification.cancel();
        }
    }

    /**
+4 −12
Changes for src/android/notification/Notification.java: 4 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ public class Notification {
            return false;

        long now       = new Date().getTime();

        long updatedAt = options.getDict().optLong("updatedAt", now);

        return (now - updatedAt) < 1000;
@@ -184,15 +183,15 @@ public class Notification {

    /**
     * Clear the local notification without canceling repeating alarms.
     *
     */
    public void clear () {
        if (!isRepeating() && wasInThePast()) {

        if (!isRepeating() && wasInThePast())
            unpersist();
        } else {

        if (!isRepeating())
            getNotMgr().cancel(getId());
    }
    }

    /**
     * Cancel the local notification.
@@ -239,13 +238,6 @@ public class Notification {
        }
    }

    /**
     * Show as modal dialog when in foreground.
     */
    private void showDialog () {
        // TODO
    }

    /**
     * Count of triggers since schedule.
     */
+4 −4
Changes for src/android/notification/Options.java: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -213,10 +213,10 @@ public class Options {
     * Trigger date in milliseconds.
     */
    public long getTriggerTime() {
        return Math.max(
                System.currentTimeMillis(),
                options.optLong("at", 0) * 1000
        );
        //return Math.max(
        //        System.currentTimeMillis(),
                return options.optLong("at", 0) * 1000;
        //);
    }

    /**