Commit 9bcabe5a by Sebastián Katzer

Cancel multiple notifications at once (iOS)

parent 0840fb0e
......@@ -10,7 +10,7 @@
- [enhancement:] Callbacks for `add`, `cancel` & `cancelAll`
- [enhancement:] `image:` accepts remote URLs and local URIs (Android)
- [enhancement:] Schedule multiple notifications at once (Android)
- [enhancement:] Cancel multiple notifications at once (Android)
- [enhancement:] Cancel multiple notifications at once
- [enhancement:] Clear multiple notifications at once (Android)
- [enhancement:] `clear` & `clearAll` methods (Android)
- [enhancement:] `onclear` event (Android)
......
......@@ -93,16 +93,22 @@
- (void) cancel:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
NSString* id = [[command arguments]
NSArray* ids = [[command arguments]
objectAtIndex:0];
for (NSString* id in ids) {
UILocalNotification* notification;
notification = [[UIApplication sharedApplication]
scheduledLocalNotificationWithId:id];
if (!notification)
continue;
[self cancelLocalNotification:notification];
[self fireEvent:@"cancel" localNotification:notification];
}
[self execCallback:command];
}];
}
......
......@@ -172,19 +172,28 @@ exports.clearAll = function (callback, scope) {
};
/**
* Cancels the specified notification.
* Cancels the specified notifications.
*
* @param {String} id
* The ID of the notification
* @param {String[]} ids
* The IDs of the notifications
* @param {Function} callback
* A function to be called after the notification has been canceled
* A function to be called after the notifications has been canceled
* @param {Object} scope
* The scope for the callback function
*/
exports.cancel = function (id, callback, scope) {
var notId = (id || '0').toString();
exports.cancel = function (ids, callback, scope) {
ids = Array.isArray(ids) ? ids : [ids];
for (var i = 0; i < ids.length; i++) {
ids[i] = ids[i].toString();
}
if (device.platform != 'iOS') {
ids = ids[0];
}
this.exec('cancel', notId, callback, scope);
this.exec('cancel', ids, callback, scope);
};
/**
......@@ -304,11 +313,7 @@ exports.registerPermission = function (callback, scope) {
* The callback function's scope
*/
exports.promptForPermission = function (callback, scope) {
console.warn(
'`notification.local.promptForPermission` is deprecated,',
'please use `notification.local.registerPermission`.'
);
console.warn('Depreated: Please use `notification.local.registerPermission` instead.');
exports.registerPermission.apply(this, arguments);
};
......@@ -613,13 +618,7 @@ exports.createCallbackFn = function (callbackFn, scope) {
*/
exports.exec = function (action, args, callback, scope) {
var fn = this.createCallbackFn(callback, scope),
params = [];
if (Array.isArray(args)) {
params = args;
} else if (args) {
params.push(args);
}
params = args ? [args] : [];
exec(fn, null, 'LocalNotification', action, params);
};
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