Commit fe66fcaf by Sebastián Katzer

Register permission when calling add

parent 856e8d0f
...@@ -112,29 +112,7 @@ exports.add = function (props, callback, scope) { ...@@ -112,29 +112,7 @@ exports.add = function (props, callback, scope) {
var options = this.mergeWithDefaults(props), var options = this.mergeWithDefaults(props),
fn = this.createCallbackFn(callback, scope); fn = this.createCallbackFn(callback, scope);
if (options.id) { this.convertOptions(options);
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 (typeof options.json == 'object') {
options.json = JSON.stringify(options.json);
}
if (['WinCE', 'Win32NT'].indexOf(device.platform) > -1) { if (['WinCE', 'Win32NT'].indexOf(device.platform) > -1) {
fn = function (cmd) { fn = function (cmd) {
...@@ -142,7 +120,11 @@ exports.add = function (props, callback, scope) { ...@@ -142,7 +120,11 @@ exports.add = function (props, callback, scope) {
}; };
} }
this.registerPermission(function(granted) {
if (granted) {
exec(fn, null, 'LocalNotification', 'add', [options]); exec(fn, null, 'LocalNotification', 'add', [options]);
}
});
return options.id; return options.id;
}; };
...@@ -511,6 +493,49 @@ exports.mergeWithDefaults = function (options) { ...@@ -511,6 +493,49 @@ exports.mergeWithDefaults = function (options) {
/** /**
* @private * @private
* *
* Convert the passed values to their required type.
*
* @param {Object} options
* Set of custom values
*
* @retrun {Object}
* The converted property list
*/
exports.convertOptions = function (options) {
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 (options.text) {
options.message = options.text.toString();
}
if (typeof options.date == 'object') {
options.date = Math.round(options.date.getTime()/1000);
}
if (typeof options.json == 'object') {
options.json = JSON.stringify(options.json);
}
return options;
};
/**
* @private
*
* Merges the platform specific properties into the default properties. * Merges the platform specific properties into the default properties.
* *
* @return {Object} * @return {Object}
......
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