Sebastián Katzer пре 11 година
родитељ
комит
823b98b31f
4 измењених фајлова са 17 додато и 11 уклоњено
  1. 1 1
      CHANGELOG.md
  2. 2 2
      README.md
  3. 2 1
      src/ios/APPLocalNotification.m
  4. 12 7
      www/local-notification.js

+ 1 - 1
CHANGELOG.md

@@ -2,7 +2,7 @@
 #### Version 0.8.0 (not yet released)
 - [enhancement:] Android 2.x (SDK >= 7) support (Thanks to **khizarsonu**)
 - [enhancement:] Scope parameter for `isScheduled` and `getScheduledIds`
-- [enhancement:] Callbacks for `cancel` & `cancelAll`
+- [enhancement:] Callbacks for `add`, `cancel` & `cancelAll`
 - [enhancement:] `image:` accepts remote URLs and local URIs (Android)
 - [feature:] New Android specific `led:` flag.
 

+ 2 - 2
README.md

@@ -72,7 +72,7 @@ More informations can be found [here][PGB_plugin].
 #### Version 0.8.0 (not yet released)
 - [enhancement:] Android 2.x (SDK >= 7) support (Thanks to **khizarsonu**)
 - [enhancement:] Scope parameter for `isScheduled` and `getScheduledIds`
-- [enhancement:] Callbacks for `cancel` & `cancelAll`
+- [enhancement:] Callbacks for `add`, `cancel` & `cancelAll`
 - [enhancement:] `image:` accepts remote URLs and local URIs (Android)
 - [feature:] New Android specific `led:` flag
 
@@ -122,7 +122,7 @@ window.plugin.notification.local.add({
     json:       String,  // Data to be passed through the notification
     autoCancel: Boolean, // Setting this flag and the notification is automatically canceled when the user clicks it
     ongoing:    Boolean, // Prevent clearing of notification (Android only)
-});
+}, callback, scope);
 ```
 
 ### Cancel scheduled local notifications

+ 2 - 1
src/ios/APPLocalNotification.m

@@ -115,6 +115,7 @@
         }
 
         [self scheduleNotificationWithProperties:properties];
+        [self execCallback:command];
     }];
 }
 
@@ -277,7 +278,7 @@
         NSTimeInterval fireDateDistance = [now timeIntervalSinceDate:
                                            fireDate];
 
-        if (notification.repeatInterval == NSEraCalendarUnit
+        if (notification.repeatInterval == NSCalendarUnitEra
             && fireDateDistance > seconds) {
             [self cancelNotification:notification fireEvent:YES];
         }

+ 12 - 7
www/local-notification.js

@@ -103,7 +103,7 @@ LocalNotification.prototype = {
             defaults.smallImage = null;
             defaults.image      = null;
             defaults.wideImage  = null;
-        };
+        }
 
         return defaults;
     },
@@ -122,11 +122,12 @@ LocalNotification.prototype = {
      *      The new callback function
      */
     createCallbackFn: function (callbackFn, scope) {
+        if (typeof callbackFn != 'function')
+            return;
+
         return function () {
-            if (typeof callbackFn == 'function') {
-                callbackFn.apply(scope || this, arguments);
-            }
-        }
+            callbackFn.apply(scope || this, arguments);
+        };
     },
 
     /**
@@ -134,13 +135,17 @@ LocalNotification.prototype = {
      *
      * @param {Object} options
      *      The notification properties
+     * @param {Function} callback
+     *      A function to be called after the notification has been canceled
+     * @param {Object} scope
+     *      The scope for the callback function
      *
      * @return {Number}
      *      The notification's ID
      */
-    add: function (options) {
+    add: function (options, callback, scope) {
         var options    = this.mergeWithDefaults(options),
-            callbackFn = null;
+            callbackFn = this.createCallbackFn(callback, scope);
 
         if (options.id) {
             options.id = options.id.toString();