Sfoglia il codice sorgente

Re-add autoCancel option on Android

Sebastián Katzer 10 anni fa
parent
commit
5dc8b66199

+ 1 - 1
src/android/notification/Builder.java

@@ -130,7 +130,7 @@ public class Builder {
                 .setTicker(options.getText())
                 .setSmallIcon(options.getSmallIcon())
                 .setLargeIcon(options.getIconBitmap())
-                .setAutoCancel(true)
+                .setAutoCancel(options.isAutoClear())
                 .setOngoing(options.isOngoing())
                 .setStyle(style)
                 .setLights(options.getLedColor(), 500, 500);

+ 8 - 1
src/android/notification/Options.java

@@ -175,12 +175,19 @@ public class Options {
     }
 
     /**
-     * Android only ongoing flag for local notifications.
+     * ongoing flag for local notifications.
      */
     public Boolean isOngoing() {
         return options.optBoolean("ongoing", false);
     }
 
+    /**
+     * autoClear flag for local notifications.
+     */
+    public Boolean isAutoClear() {
+        return options.optBoolean("autoClear", false);
+    }
+
     /**
      * Trigger date in milliseconds.
      */

+ 7 - 0
www/local-notification-util.js

@@ -63,6 +63,7 @@ exports.applyPlatformSpecificOptions = function () {
         defaults.icon      = 'res://icon';
         defaults.smallIcon = 'res://ic_popup_reminder';
         defaults.ongoing   = false;
+        defaults.autoClear = true;
         defaults.led       = 'FFFFFF';
         break;
     }
@@ -86,6 +87,12 @@ exports.mergeWithDefaults = function (options) {
     options.text = this.getValueFor(options, 'text', 'message');
     options.data = this.getValueFor(options, 'data', 'json');
 
+    options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
+
+    if (options.autoClear !== true && options.ongoing) {
+        options.autoClear = false;
+    }
+
     if (options.at === undefined || options.at === null) {
         options.at = new Date();
     }