Commit 7fc01db0 by Sebastián Katzer

Add scope parameter for `isScheduled` and `getScheduledIds`

parent afd6a480
......@@ -146,7 +146,7 @@ window.plugin.notification.local.cancelAll();
### 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>
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
- 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
```javascript
window.plugin.notification.local.isScheduled(id, function (isScheduled) {
// console.log('Notification with ID ' + id + ' is scheduled: ' + isScheduled);
});
}, scope);
```
### 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>
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
window.plugin.notification.local.getScheduledIds( function (scheduledIds) {
window.plugin.notification.local.getScheduledIds(function (scheduledIds) {
// alert('Scheduled IDs: ' + scheduledIds.join(' ,'));
});
}, scope);
```
### Get the default values of the local notification properties
......
......@@ -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
*
* @param {Object} options
......@@ -167,9 +186,13 @@ LocalNotification.prototype = {
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object} scope
* The scope for the callback function
*/
getScheduledIds: function (callback) {
cordova.exec(callback, null, 'LocalNotification', 'getScheduledIds', []);
getScheduledIds: function (callback, scope) {
var callbackFn = this.createCallbackFn(callback, scope);
cordova.exec(callbackFn, null, 'LocalNotification', 'getScheduledIds', []);
},
/**
......@@ -179,11 +202,14 @@ LocalNotification.prototype = {
* The ID of the notification
* @param {Function} callback
* A callback function to be called with the list
* @param {Object} scope
* The scope for the callback function
*/
isScheduled: function (id, callback) {
var id = id.toString();
isScheduled: function (id, callback, scope) {
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