Commit 823b98b3 by Sebastián Katzer

Add callback to `add`

parent 86975e60
......@@ -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.
......
......@@ -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
......
......@@ -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];
}
......
......@@ -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();
......
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