Commit c88dd6ec by Sebastián Katzer

Invoke callback for schedule/update with boolean arg if the permission

is granted [Fixes #1187]
parent 7ba39d66
...@@ -142,11 +142,11 @@ public class LocalNotification extends CordovaPlugin { ...@@ -142,11 +142,11 @@ public class LocalNotification extends CordovaPlugin {
} else } else
if (action.equalsIgnoreCase("schedule")) { if (action.equalsIgnoreCase("schedule")) {
schedule(args); schedule(args);
command.success(); check(command);
} else } else
if (action.equals("update")) { if (action.equals("update")) {
update(args); update(args);
command.success(); check(command);
} else } else
if (action.equals("cancel")) { if (action.equals("cancel")) {
cancel(args); cancel(args);
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
[self scheduleNotification:notification]; [self scheduleNotification:notification];
} }
[self execCallback:command]; [self check:command];
}]; }];
} }
...@@ -131,8 +131,8 @@ ...@@ -131,8 +131,8 @@
[self fireEvent:@"update" notification:notification]; [self fireEvent:@"update" notification:notification];
} }
[self execCallback:command]; [self check:command];
}]; }];
} }
...@@ -613,7 +613,9 @@ ...@@ -613,7 +613,9 @@
} }
/** /**
* Simply invokes the callback without any parameter. * Invokes the callback without any parameter.
*
* @return [ Void ]
*/ */
- (void) execCallback:(CDVInvokedUrlCommand*)command - (void) execCallback:(CDVInvokedUrlCommand*)command
{ {
......
...@@ -107,7 +107,7 @@ exports.schedule = function (success, error, args) { ...@@ -107,7 +107,7 @@ exports.schedule = function (success, error, args) {
exports.fireEvent('add', toast); exports.fireEvent('add', toast);
} }
success(); exports.check(success, error);
}; };
/** /**
...@@ -133,7 +133,7 @@ exports.update = function (success, error, args) { ...@@ -133,7 +133,7 @@ exports.update = function (success, error, args) {
exports.fireEvent('update', toast); exports.fireEvent('update', toast);
} }
success(); exports.check(success, error);
}; };
/** /**
......
...@@ -61,11 +61,13 @@ exports.requestPermission = function (callback, scope) { ...@@ -61,11 +61,13 @@ exports.requestPermission = function (callback, scope) {
*/ */
exports.schedule = function (msgs, callback, scope, args) { exports.schedule = function (msgs, callback, scope, args) {
var fn = function (granted) { var fn = function (granted) {
if (!granted) return;
var toasts = this.toArray(msgs); var toasts = this.toArray(msgs);
if (!granted && callback) {
callback.call(scope || this, false);
return;
}
for (var toast of toasts) { for (var toast of toasts) {
this.mergeWithDefaults(toast); this.mergeWithDefaults(toast);
this.convertProperties(toast); this.convertProperties(toast);
...@@ -93,13 +95,16 @@ exports.schedule = function (msgs, callback, scope, args) { ...@@ -93,13 +95,16 @@ exports.schedule = function (msgs, callback, scope, args) {
*/ */
exports.update = function (msgs, callback, scope, args) { exports.update = function (msgs, callback, scope, args) {
var fn = function(granted) { var fn = function(granted) {
if (!granted) return;
var toasts = this.toArray(msgs); var toasts = this.toArray(msgs);
if (!granted && callback) {
callback.call(scope || this, false);
return;
}
for (var toast of toasts) { for (var toast of toasts) {
this.convertProperties(toast); } this.convertProperties(toast);
}
this.exec('update', toasts, callback, scope); this.exec('update', toasts, callback, scope);
}; };
......
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