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

Add callback to `add`

parent 86975e60
Loading
Loading
Loading
Loading
+1 −1
Changes for CHANGELOG.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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
Changes for README.md: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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
Changes for src/ios/APPLocalNotification.m: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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];
        }
+11 −6
Changes for www/local-notification.js: 11 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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);
            }
        }
        };
    },

    /**
@@ -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();