Эх сурвалжийг харах

Fire `clear` instead of `cancel` when clicked on repeating notifications

Sebastián Katzer 10 жил өмнө
parent
commit
b8d9e14202

+ 4 - 0
CHANGELOG.md

@@ -3,6 +3,10 @@ ChangeLog
 
 Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-local-notifications/wiki/Upgrade-Guide) for more information.
 
+#### Version 0.8.1 (not yet released)
+
+- Fire `clear` instead of `cancel` event when clicked on repeating notifications
+
 ### Version 0.8.0 (05.03.2015)
 
 - Support for iOS 8, Android 2 (SDK >= 7) and Android 5

+ 3 - 3
src/android/ClickActivity.java

@@ -43,9 +43,9 @@ public class ClickActivity extends de.appplant.cordova.plugin.notification.Click
     public void onClick(Notification notification) {
         LocalNotification.fireEvent("click", notification);
 
-        if (!notification.isRepeating()) {
-            LocalNotification.fireEvent("cancel", notification);
-        }
+        String event = notification.isRepeating() ? "clear" : "cancel";
+
+        LocalNotification.fireEvent(event, notification);
 
         super.onClick(notification);
     }

+ 6 - 3
src/ios/APPLocalNotification.m

@@ -501,7 +501,6 @@
             && notification.timeIntervalSinceFireDate > seconds)
         {
             [self.app cancelLocalNotification:notification];
-
             [self fireEvent:@"cancel" notification:notification];
         }
     }
@@ -527,8 +526,12 @@
 
     [self fireEvent:event notification:notification];
 
-    if ([event isEqualToString:@"click"] && ![notification isRepeating])
-    {
+    if (![event isEqualToString:@"click"])
+        return;
+
+    if ([notification isRepeating]) {
+        [self fireEvent:@"clear" notification:notification];
+    } else {
         [self.app cancelLocalNotification:notification];
         [self fireEvent:@"cancel" notification:notification];
     }