|
|
@@ -147,6 +147,128 @@ exports.add = function (props, callback, scope) {
|
|
|
return options.id;
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Add new entries to the registry (more than one)
|
|
|
+ *
|
|
|
+ * @param {Object} options
|
|
|
+ * The notification properties
|
|
|
+ * @param {Function} callback
|
|
|
+ * A function to be called after the notification has been added
|
|
|
+ * @param {Object} scope
|
|
|
+ * The scope for the callback function
|
|
|
+ *
|
|
|
+ * @return {Number}
|
|
|
+ * The notification's ID
|
|
|
+ */
|
|
|
+exports.addMultiple = function (notifications, callback, scope) {
|
|
|
+ var length = notifications.length;
|
|
|
+ var notificationsMerged = new Array(),
|
|
|
+ callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ for (var i=0;i<length;i++){
|
|
|
+ var options = this.mergeWithDefaults(notifications[i]);
|
|
|
+ if (options.id) {
|
|
|
+ options.id = options.id.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (options.date === undefined) {
|
|
|
+ options.date = new Date();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (options.title) {
|
|
|
+ options.title = options.title.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (options.message) {
|
|
|
+ options.message = options.message.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typeof options.date == 'object') {
|
|
|
+ options.date = Math.round(options.date.getTime()/1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (['WinCE', 'Win32NT'].indexOf(device.platform) > -1) {
|
|
|
+ callbackFn = function (cmd) {
|
|
|
+ eval(cmd);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ notificationsMerged.push(options);
|
|
|
+ }
|
|
|
+
|
|
|
+ cordova.exec(callbackFn, null, 'LocalNotification', 'addMultiple', notificationsMerged);
|
|
|
+
|
|
|
+ return options.id;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Update existing notification (currently android only)
|
|
|
+ *
|
|
|
+ * @param {Object} options
|
|
|
+ * The notification properties to update
|
|
|
+ * @param {Function} callback
|
|
|
+ * A function to be called after the notification has been updated
|
|
|
+ * @param {Object} scope
|
|
|
+ * The scope for the callback function
|
|
|
+ *
|
|
|
+ * @return {Number}
|
|
|
+ * The notification's ID
|
|
|
+ */
|
|
|
+exports.update = function (updates, callback, scope) {
|
|
|
+ callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ cordova.exec(callbackFn, null, 'LocalNotification', 'update', [updates]);
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Clears the specified notification.
|
|
|
+ *
|
|
|
+ * @param {String} id
|
|
|
+ * The ID of the notification
|
|
|
+ * @param {Function} callback
|
|
|
+ * A function to be called after the notification has been cleared
|
|
|
+ * @param {Object} scope
|
|
|
+ * The scope for the callback function
|
|
|
+ */
|
|
|
+exports.clear = function (id, callback, scope) {
|
|
|
+ var id = id.toString(),
|
|
|
+ callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ cordova.exec(callbackFn, null, 'LocalNotification', 'clear', [id]);
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Clear the specified notifications (more than one).
|
|
|
+ *
|
|
|
+ * @param {String} id
|
|
|
+ * The ID of the notification
|
|
|
+ * @param {Function} callback
|
|
|
+ * A function to be called after the notifications has been cleared.
|
|
|
+ * @param {Object} scope
|
|
|
+ * The scope for the callback function
|
|
|
+ */
|
|
|
+exports.clearMultiple = function (ids, callback, scope) {
|
|
|
+ var length = ids.length;
|
|
|
+ var idArray = new Array(),
|
|
|
+ callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ for (var i=0;i<length;i++){
|
|
|
+ var id = ids[i].toString();
|
|
|
+ idArray.push(id);
|
|
|
+ }
|
|
|
+ var callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ cordova.exec(callbackFn, null, 'LocalNotification', 'clearMultiple', [ids]);
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * Clears all previously sheduled notifications.
|
|
|
+ *
|
|
|
+ * @param {Function} callback
|
|
|
+ * A function to be called after all notifications have been cleared
|
|
|
+ * @param {Object} scope
|
|
|
+ * The scope for the callback function
|
|
|
+ */
|
|
|
+exports.clearAll = function (callback, scope) {
|
|
|
+ var callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+
|
|
|
+ cordova.exec(callbackFn, null, 'LocalNotification', 'clearAll', []);
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* Cancels the specified notification.
|
|
|
*
|
|
|
@@ -163,6 +285,28 @@ exports.cancel = function (id, callback, scope) {
|
|
|
exec(fn, null, 'LocalNotification', 'cancel', [(id || '0').toString()]);
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Cancel the specified notifications (more than one).
|
|
|
+ *
|
|
|
+ * @param {String} id
|
|
|
+ * The ID of the notification
|
|
|
+ * @param {Function} callback
|
|
|
+ * A function to be called after the notifications has been canceled
|
|
|
+ * @param {Object} scope
|
|
|
+ * The scope for the callback function
|
|
|
+ */
|
|
|
+exports.cancelMultiple = function (ids, callback, scope) {
|
|
|
+ var length = ids.length;
|
|
|
+ var idArray = new Array(),
|
|
|
+ callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ for (var i=0;i<length;i++){
|
|
|
+ var id = ids[i].toString();
|
|
|
+ idArray.push(id);
|
|
|
+ }
|
|
|
+ var callbackFn = this.createCallbackFn(callback, scope);
|
|
|
+ cordova.exec(callbackFn, null, 'LocalNotification', 'cancelMultiple', [ids]);
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* Removes all previously registered notifications.
|
|
|
*
|
|
|
@@ -328,6 +472,18 @@ exports.onclick = function (id, state, json) {};
|
|
|
*/
|
|
|
exports.oncancel = function (id, state, json) {};
|
|
|
|
|
|
+/**
|
|
|
+ * Get fired when the notification was cleared.
|
|
|
+ *
|
|
|
+ * @param {String} id
|
|
|
+ * The ID of the notification
|
|
|
+ * @param {String} state
|
|
|
+ * Either "foreground" or "background"
|
|
|
+ * @param {String} json
|
|
|
+ * A custom (JSON) string
|
|
|
+ */
|
|
|
+exports.onclear = function (id, state, json) {};
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @private
|