Commit 7fc01db0 by Sebastián Katzer

Add scope parameter for `isScheduled` and `getScheduledIds`

parent afd6a480
...@@ -146,7 +146,7 @@ window.plugin.notification.local.cancelAll(); ...@@ -146,7 +146,7 @@ window.plugin.notification.local.cancelAll();
### Check wether a notification with an ID is scheduled ### Check wether a notification with an ID is scheduled
To check if a notification with an ID is scheduled, the `notification.local.isScheduled` interface can be used.<br> To check if a notification with an ID is scheduled, the `notification.local.isScheduled` interface can be used.<br>
The method takes the ID of the local notification as an argument and a callback function to be called with the result. The method takes the ID of the local notification as an argument and a callback function to be called with the result. Optional the scope of the callback can be assigned too.
#### Further informations #### Further informations
- See [getScheduledIds][getscheduledids] of how to retrieve a list of IDs of all scheduled local notifications. - See [getScheduledIds][getscheduledids] of how to retrieve a list of IDs of all scheduled local notifications.
...@@ -154,17 +154,17 @@ The method takes the ID of the local notification as an argument and a callback ...@@ -154,17 +154,17 @@ The method takes the ID of the local notification as an argument and a callback
```javascript ```javascript
window.plugin.notification.local.isScheduled(id, function (isScheduled) { window.plugin.notification.local.isScheduled(id, function (isScheduled) {
// console.log('Notification with ID ' + id + ' is scheduled: ' + isScheduled); // console.log('Notification with ID ' + id + ' is scheduled: ' + isScheduled);
}); }, scope);
``` ```
### Retrieve the IDs from all currently scheduled local notifications ### Retrieve the IDs from all currently scheduled local notifications
To retrieve the IDs from all currently scheduled local notifications, the `notification.local.isScheduled` interface can be used.<br> To retrieve the IDs from all currently scheduled local notifications, the `notification.local.isScheduled` interface can be used.<br>
The method takes a callback function to be called with the result as an array of IDs. The method takes a callback function to be called with the result as an array of IDs. Optional the scope of the callback can be assigned too.
```javascript ```javascript
window.plugin.notification.local.getScheduledIds( function (scheduledIds) { window.plugin.notification.local.getScheduledIds(function (scheduledIds) {
// alert('Scheduled IDs: ' + scheduledIds.join(' ,')); // alert('Scheduled IDs: ' + scheduledIds.join(' ,'));
}); }, scope);
``` ```
### Get the default values of the local notification properties ### Get the default values of the local notification properties
......
...@@ -108,6 +108,25 @@ LocalNotification.prototype = { ...@@ -108,6 +108,25 @@ LocalNotification.prototype = {
}, },
/** /**
* @private
*
* Creates a callback, which will be executed within a specific scope.
*
* @param {Function} callbackFn
* The callback function
* @param {Object} scope
* The scope for the function
*
* @return {Function}
* The new callback function
*/
createCallbackFn: function (callbackFn, scope) {
return function () {
callbackFn.apply(arguments, scope || this);
}
},
/**
* Add a new entry to the registry * Add a new entry to the registry
* *
* @param {Object} options * @param {Object} options
...@@ -167,9 +186,13 @@ LocalNotification.prototype = { ...@@ -167,9 +186,13 @@ LocalNotification.prototype = {
* *
* @param {Function} callback * @param {Function} callback
* A callback function to be called with the list * A callback function to be called with the list
* @param {Object} scope
* The scope for the callback function
*/ */
getScheduledIds: function (callback) { getScheduledIds: function (callback, scope) {
cordova.exec(callback, null, 'LocalNotification', 'getScheduledIds', []); var callbackFn = this.createCallbackFn(callback, scope);
cordova.exec(callbackFn, null, 'LocalNotification', 'getScheduledIds', []);
}, },
/** /**
...@@ -179,11 +202,14 @@ LocalNotification.prototype = { ...@@ -179,11 +202,14 @@ LocalNotification.prototype = {
* The ID of the notification * The ID of the notification
* @param {Function} callback * @param {Function} callback
* A callback function to be called with the list * A callback function to be called with the list
* @param {Object} scope
* The scope for the callback function
*/ */
isScheduled: function (id, callback) { isScheduled: function (id, callback, scope) {
var id = id.toString(); var id = id.toString(),
callbackFn = this.createCallbackFn(callback, scope);
cordova.exec(callback, null, 'LocalNotification', 'isScheduled', [id]); cordova.exec(callbackFn, null, 'LocalNotification', 'isScheduled', [id]);
}, },
/** /**
......
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