Commit 823b98b3 by Sebastián Katzer

Add callback to `add`

parent 86975e60
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#### Version 0.8.0 (not yet released) #### Version 0.8.0 (not yet released)
- [enhancement:] Android 2.x (SDK >= 7) support (Thanks to **khizarsonu**) - [enhancement:] Android 2.x (SDK >= 7) support (Thanks to **khizarsonu**)
- [enhancement:] Scope parameter for `isScheduled` and `getScheduledIds` - [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) - [enhancement:] `image:` accepts remote URLs and local URIs (Android)
- [feature:] New Android specific `led:` flag. - [feature:] New Android specific `led:` flag.
......
...@@ -72,7 +72,7 @@ More informations can be found [here][PGB_plugin]. ...@@ -72,7 +72,7 @@ More informations can be found [here][PGB_plugin].
#### Version 0.8.0 (not yet released) #### Version 0.8.0 (not yet released)
- [enhancement:] Android 2.x (SDK >= 7) support (Thanks to **khizarsonu**) - [enhancement:] Android 2.x (SDK >= 7) support (Thanks to **khizarsonu**)
- [enhancement:] Scope parameter for `isScheduled` and `getScheduledIds` - [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) - [enhancement:] `image:` accepts remote URLs and local URIs (Android)
- [feature:] New Android specific `led:` flag - [feature:] New Android specific `led:` flag
...@@ -122,7 +122,7 @@ window.plugin.notification.local.add({ ...@@ -122,7 +122,7 @@ window.plugin.notification.local.add({
json: String, // Data to be passed through the notification 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 autoCancel: Boolean, // Setting this flag and the notification is automatically canceled when the user clicks it
ongoing: Boolean, // Prevent clearing of notification (Android only) ongoing: Boolean, // Prevent clearing of notification (Android only)
}); }, callback, scope);
``` ```
### Cancel scheduled local notifications ### Cancel scheduled local notifications
......
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
} }
[self scheduleNotificationWithProperties:properties]; [self scheduleNotificationWithProperties:properties];
[self execCallback:command];
}]; }];
} }
...@@ -277,7 +278,7 @@ ...@@ -277,7 +278,7 @@
NSTimeInterval fireDateDistance = [now timeIntervalSinceDate: NSTimeInterval fireDateDistance = [now timeIntervalSinceDate:
fireDate]; fireDate];
if (notification.repeatInterval == NSEraCalendarUnit if (notification.repeatInterval == NSCalendarUnitEra
&& fireDateDistance > seconds) { && fireDateDistance > seconds) {
[self cancelNotification:notification fireEvent:YES]; [self cancelNotification:notification fireEvent:YES];
} }
......
...@@ -103,7 +103,7 @@ LocalNotification.prototype = { ...@@ -103,7 +103,7 @@ LocalNotification.prototype = {
defaults.smallImage = null; defaults.smallImage = null;
defaults.image = null; defaults.image = null;
defaults.wideImage = null; defaults.wideImage = null;
}; }
return defaults; return defaults;
}, },
...@@ -122,11 +122,12 @@ LocalNotification.prototype = { ...@@ -122,11 +122,12 @@ LocalNotification.prototype = {
* The new callback function * The new callback function
*/ */
createCallbackFn: function (callbackFn, scope) { createCallbackFn: function (callbackFn, scope) {
if (typeof callbackFn != 'function')
return;
return function () { return function () {
if (typeof callbackFn == 'function') {
callbackFn.apply(scope || this, arguments); callbackFn.apply(scope || this, arguments);
} };
}
}, },
/** /**
...@@ -134,13 +135,17 @@ LocalNotification.prototype = { ...@@ -134,13 +135,17 @@ LocalNotification.prototype = {
* *
* @param {Object} options * @param {Object} options
* The notification properties * 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} * @return {Number}
* The notification's ID * The notification's ID
*/ */
add: function (options) { add: function (options, callback, scope) {
var options = this.mergeWithDefaults(options), var options = this.mergeWithDefaults(options),
callbackFn = null; callbackFn = this.createCallbackFn(callback, scope);
if (options.id) { if (options.id) {
options.id = options.id.toString(); 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