Commit d74caf68 by Sebastián Katzer

Fix getIds returns none existing notifications

parent 829501a9
...@@ -44,13 +44,13 @@ public class ClickActivity extends de.appplant.cordova.plugin.notification.Click ...@@ -44,13 +44,13 @@ public class ClickActivity extends de.appplant.cordova.plugin.notification.Click
public void onClick(Notification notification) { public void onClick(Notification notification) {
LocalNotification.fireEvent("click", notification); LocalNotification.fireEvent("click", notification);
if (!notification.getOptions().isOngoing()) { super.onClick(notification);
String event = notification.isRepeating() ? "clear" : "cancel";
LocalNotification.fireEvent(event, notification); if (notification.getOptions().isOngoing())
} return;
super.onClick(notification); String event = notification.isRepeating() ? "clear" : "cancel";
LocalNotification.fireEvent(event, notification);
} }
/** /**
......
...@@ -40,6 +40,12 @@ public class ClickActivity extends AbstractClickActivity { ...@@ -40,6 +40,12 @@ public class ClickActivity extends AbstractClickActivity {
@Override @Override
public void onClick(Notification notification) { public void onClick(Notification notification) {
launchApp(); launchApp();
if (notification.isRepeating()) {
notification.clear();
} else {
notification.cancel();
}
} }
/** /**
......
...@@ -144,8 +144,7 @@ public class Notification { ...@@ -144,8 +144,7 @@ public class Notification {
if (!options.getDict().has("updatedAt")) if (!options.getDict().has("updatedAt"))
return false; return false;
long now = new Date().getTime(); long now = new Date().getTime();
long updatedAt = options.getDict().optLong("updatedAt", now); long updatedAt = options.getDict().optLong("updatedAt", now);
return (now - updatedAt) < 1000; return (now - updatedAt) < 1000;
...@@ -184,14 +183,14 @@ public class Notification { ...@@ -184,14 +183,14 @@ public class Notification {
/** /**
* Clear the local notification without canceling repeating alarms. * Clear the local notification without canceling repeating alarms.
*
*/ */
public void clear () { public void clear () {
if (!isRepeating() && wasInThePast()) {
if (!isRepeating() && wasInThePast())
unpersist(); unpersist();
} else {
if (!isRepeating())
getNotMgr().cancel(getId()); getNotMgr().cancel(getId());
}
} }
/** /**
...@@ -240,13 +239,6 @@ public class Notification { ...@@ -240,13 +239,6 @@ public class Notification {
} }
/** /**
* Show as modal dialog when in foreground.
*/
private void showDialog () {
// TODO
}
/**
* Count of triggers since schedule. * Count of triggers since schedule.
*/ */
public int getTriggerCountSinceSchedule() { public int getTriggerCountSinceSchedule() {
......
...@@ -213,10 +213,10 @@ public class Options { ...@@ -213,10 +213,10 @@ public class Options {
* Trigger date in milliseconds. * Trigger date in milliseconds.
*/ */
public long getTriggerTime() { public long getTriggerTime() {
return Math.max( //return Math.max(
System.currentTimeMillis(), // System.currentTimeMillis(),
options.optLong("at", 0) * 1000 return options.optLong("at", 0) * 1000;
); //);
} }
/** /**
......
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