Loading README.md +18 −0 Changes for README.md: 18 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356). #### Version 0.7.0 (not yet released) - **Note:** The new way of callback registration will be not compatible with previous versions! See #62 - [feature:] Added new callback registration interface and new callback types. - [feature:] Added the ability to override notifications default properties. #### Version 0.7.0beta1 (17.01.2014) - [bugfix:] App throws an error on iOS if `message` is null. Loading Loading @@ -149,6 +150,18 @@ There are 4 different callback types available. For each of them one listener ca window.plugin.notification.local.on_callback_ = function (id, state, json) {}; ``` ### getDefaults() Gives an overview about all available notification properties for the platform and their default values. The function returns an object. ```javascript window.plugin.notification.local.getDefaults(); ``` ### setDefaults () Overrides the default properties. The function takes an object as argument. ```javascript window.plugin.notification.local.setDefaults(Object); ``` ## Examples #### Will fire every week on this day, 60 seconds from now Loading Loading @@ -193,6 +206,11 @@ window.plugin.notification.local.onclick = function (id, state, json) { } ``` ### Change the default value for autoCancel ```javascript window.plugin.notification.local.setDefaults({ autoCancel: true }); ``` ## Platform specifics ### Small and large icons on Android Loading www/local-notification.js +74 −23 Changes for www/local-notification.js: 74 added lines, 23 removed lines. Original line number Diff line number Diff line Loading @@ -20,19 +20,7 @@ */ var LocalNotification = function () { }; LocalNotification.prototype = { /** * Fügt einen neuen Eintrag zur Registry hinzu. * * @param {Object} options * @return {Number} Die ID der Notification */ add: function (options) { var defaults = { date: new Date(), this._deafults = { message: '', title: '', autoCancel: false, Loading @@ -42,6 +30,57 @@ LocalNotification.prototype = { json: '', repeat: '' }; }; LocalNotification.prototype = { /** * Gibt alle Standardeinstellungen an. * * @return {Object} */ getDefaults: function () { return this._deafults; }, /** * Überschreibt die Standardeinstellungen. * * @param {Object} defaults */ setDefaults: function (newDefaults) { var defaults = this.getDefaults(); for (var key in defaults) { if (newDefaults[key] !== undefined) { defaults[key] = newDefaults[key]; } } }, /** * @private * Merged die Eigenschaften mit den Standardwerten. * * @param {Object} options * @retrun {Object} */ mergeWithDefaults: function (options) { var defaults = this.getDefaults(); for (var key in defaults) { if (options[key] === undefined) { options[key] = defaults[key]; } } return options; }, /** * @private */ applyPlatformSpecificOptions: function () { var defaults = this._deafults; switch (device.platform) { case 'Android': Loading @@ -55,24 +94,32 @@ LocalNotification.prototype = { defaults.image = null; defaults.wideImage = null; }; }, for (var key in defaults) { if (options[key] !== undefined) { defaults[key] = options[key]; } /** * Fügt einen neuen Eintrag zur Registry hinzu. * * @param {Object} options * @return {Number} Die ID der Notification */ add: function (options) { var options = this.mergeWithDefaults(options); if (options.id) { options.id = options.id.toString(); } if (defaults.id) { defaults.id = defaults.id.toString(); if (options.date === undefined) { options.date = new Date(); } if (typeof defaults.date == 'object') { defaults.date = Math.round(defaults.date.getTime()/1000); if (typeof options.date == 'object') { options.date = Math.round(options.date.getTime()/1000); } cordova.exec(null, null, 'LocalNotification', 'add', [defaults]); cordova.exec(null, null, 'LocalNotification', 'add', [options]); return defaults.id; return options.id; }, /** Loading Loading @@ -130,4 +177,8 @@ LocalNotification.prototype = { var plugin = new LocalNotification(); document.addEventListener('deviceready', function () { plugin.applyPlatformSpecificOptions(); }, false); module.exports = plugin; Loading
README.md +18 −0 Changes for README.md: 18 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356). #### Version 0.7.0 (not yet released) - **Note:** The new way of callback registration will be not compatible with previous versions! See #62 - [feature:] Added new callback registration interface and new callback types. - [feature:] Added the ability to override notifications default properties. #### Version 0.7.0beta1 (17.01.2014) - [bugfix:] App throws an error on iOS if `message` is null. Loading Loading @@ -149,6 +150,18 @@ There are 4 different callback types available. For each of them one listener ca window.plugin.notification.local.on_callback_ = function (id, state, json) {}; ``` ### getDefaults() Gives an overview about all available notification properties for the platform and their default values. The function returns an object. ```javascript window.plugin.notification.local.getDefaults(); ``` ### setDefaults () Overrides the default properties. The function takes an object as argument. ```javascript window.plugin.notification.local.setDefaults(Object); ``` ## Examples #### Will fire every week on this day, 60 seconds from now Loading Loading @@ -193,6 +206,11 @@ window.plugin.notification.local.onclick = function (id, state, json) { } ``` ### Change the default value for autoCancel ```javascript window.plugin.notification.local.setDefaults({ autoCancel: true }); ``` ## Platform specifics ### Small and large icons on Android Loading
www/local-notification.js +74 −23 Changes for www/local-notification.js: 74 added lines, 23 removed lines. Original line number Diff line number Diff line Loading @@ -20,19 +20,7 @@ */ var LocalNotification = function () { }; LocalNotification.prototype = { /** * Fügt einen neuen Eintrag zur Registry hinzu. * * @param {Object} options * @return {Number} Die ID der Notification */ add: function (options) { var defaults = { date: new Date(), this._deafults = { message: '', title: '', autoCancel: false, Loading @@ -42,6 +30,57 @@ LocalNotification.prototype = { json: '', repeat: '' }; }; LocalNotification.prototype = { /** * Gibt alle Standardeinstellungen an. * * @return {Object} */ getDefaults: function () { return this._deafults; }, /** * Überschreibt die Standardeinstellungen. * * @param {Object} defaults */ setDefaults: function (newDefaults) { var defaults = this.getDefaults(); for (var key in defaults) { if (newDefaults[key] !== undefined) { defaults[key] = newDefaults[key]; } } }, /** * @private * Merged die Eigenschaften mit den Standardwerten. * * @param {Object} options * @retrun {Object} */ mergeWithDefaults: function (options) { var defaults = this.getDefaults(); for (var key in defaults) { if (options[key] === undefined) { options[key] = defaults[key]; } } return options; }, /** * @private */ applyPlatformSpecificOptions: function () { var defaults = this._deafults; switch (device.platform) { case 'Android': Loading @@ -55,24 +94,32 @@ LocalNotification.prototype = { defaults.image = null; defaults.wideImage = null; }; }, for (var key in defaults) { if (options[key] !== undefined) { defaults[key] = options[key]; } /** * Fügt einen neuen Eintrag zur Registry hinzu. * * @param {Object} options * @return {Number} Die ID der Notification */ add: function (options) { var options = this.mergeWithDefaults(options); if (options.id) { options.id = options.id.toString(); } if (defaults.id) { defaults.id = defaults.id.toString(); if (options.date === undefined) { options.date = new Date(); } if (typeof defaults.date == 'object') { defaults.date = Math.round(defaults.date.getTime()/1000); if (typeof options.date == 'object') { options.date = Math.round(options.date.getTime()/1000); } cordova.exec(null, null, 'LocalNotification', 'add', [defaults]); cordova.exec(null, null, 'LocalNotification', 'add', [options]); return defaults.id; return options.id; }, /** Loading Loading @@ -130,4 +177,8 @@ LocalNotification.prototype = { var plugin = new LocalNotification(); document.addEventListener('deviceready', function () { plugin.applyPlatformSpecificOptions(); }, false); module.exports = plugin;