diff --git a/Example/www/PushNotification.js b/Example/www/PushNotification.js index 6b51bade..8c10bf22 100644 --- a/Example/www/PushNotification.js +++ b/Example/www/PushNotification.js @@ -1,65 +1,78 @@ - var PushNotification = function() { }; +// Call this to register for push notifications. Content of [options] depends on whether we are working with APNS (iOS) or GCM (Android) +PushNotification.prototype.register = function(successCallback, errorCallback, options) { + if (errorCallback == null) { errorCallback = function() {}} + + if (typeof errorCallback != "function") { + console.log("PushNotification.register failure: failure parameter not a function"); + return + } + + if (typeof successCallback != "function") { + console.log("PushNotification.register failure: success callback parameter must be a function"); + return + } + + cordova.exec(successCallback, errorCallback, "PushPlugin", "register", [options]); +}; - // Call this to register for push notifications. Content of [options] depends on whether we are working with APNS (iOS) or GCM (Android) - PushNotification.prototype.register = function(successCallback, errorCallback, options) { - if (errorCallback == null) { errorCallback = function() {}} +// Call this to unregister for push notifications +PushNotification.prototype.unregister = function(successCallback, errorCallback, options) { + if (errorCallback == null) { errorCallback = function() {}} - if (typeof errorCallback != "function") { - console.log("PushNotification.register failure: failure parameter not a function"); - return; - } + if (typeof errorCallback != "function") { + console.log("PushNotification.unregister failure: failure parameter not a function"); + return + } - if (typeof successCallback != "function") { - console.log("PushNotification.register failure: success callback parameter must be a function"); - return; - } + if (typeof successCallback != "function") { + console.log("PushNotification.unregister failure: success callback parameter must be a function"); + return + } - cordova.exec(successCallback, errorCallback, "PushPlugin", "register", [options]); - }; + cordova.exec(successCallback, errorCallback, "PushPlugin", "unregister", [options]); +}; - // Call this to unregister for push notifications - PushNotification.prototype.unregister = function(successCallback, errorCallback) { - if (errorCallback == null) { errorCallback = function() {}} +// Call this if you want to show toast notification on WP8 +PushNotification.prototype.showToastNotification = function (successCallback, errorCallback, options) { + if (errorCallback == null) { errorCallback = function () { } } - if (typeof errorCallback != "function") { - console.log("PushNotification.unregister failure: failure parameter not a function"); - return; - } + if (typeof errorCallback != "function") { + console.log("PushNotification.register failure: failure parameter not a function"); + return + } - if (typeof successCallback != "function") { - console.log("PushNotification.unregister failure: success callback parameter must be a function"); - return; - } + cordova.exec(successCallback, errorCallback, "PushPlugin", "showToastNotification", [options]); +} - cordova.exec(successCallback, errorCallback, "PushPlugin", "unregister", []); - }; - - - // Call this to set the application icon badge - PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, badge) { - if (errorCallback == null) { errorCallback = function() {}} +// Call this to set the application icon badge +PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) { + if (errorCallback == null) { errorCallback = function() {}} - if (typeof errorCallback != "function") { - console.log("PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function"); - return; - } + if (typeof errorCallback != "function") { + console.log("PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function"); + return + } - if (typeof successCallback != "function") { - console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function"); - return; - } + if (typeof successCallback != "function") { + console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function"); + return + } - cordova.exec(successCallback, successCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]); - }; + cordova.exec(successCallback, errorCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]); +}; //------------------------------------------------------------------- -if(!window.plugins) { - window.plugins = {}; +if (!window.plugins) { + window.plugins = {}; } if (!window.plugins.pushNotification) { - window.plugins.pushNotification = new PushNotification(); + window.plugins.pushNotification = new PushNotification(); +} + +if (typeof module != 'undefined' && module.exports) { + module.exports = PushNotification; } diff --git a/Example/www/index.html b/Example/www/index.html index e6e2cd17..c118fb01 100755 --- a/Example/www/index.html +++ b/Example/www/index.html @@ -14,22 +14,22 @@ To add them via the CLI: $ cordova plugin add org.apache.cordova.device $ cordova plugin add org.apache.cordova.media -*/ +*/ - + diff --git a/www/PushNotification.js b/www/PushNotification.js index 6127cf56..8c10bf22 100644 --- a/www/PushNotification.js +++ b/www/PushNotification.js @@ -1,7 +1,6 @@ var PushNotification = function() { }; - // Call this to register for push notifications. Content of [options] depends on whether we are working with APNS (iOS) or GCM (Android) PushNotification.prototype.register = function(successCallback, errorCallback, options) { if (errorCallback == null) { errorCallback = function() {}} @@ -36,17 +35,18 @@ PushNotification.prototype.unregister = function(successCallback, errorCallback, cordova.exec(successCallback, errorCallback, "PushPlugin", "unregister", [options]); }; - // Call this if you want to show toast notification on WP8 - PushNotification.prototype.showToastNotification = function (successCallback, errorCallback, options) { - if (errorCallback == null) { errorCallback = function () { } } - - if (typeof errorCallback != "function") { - console.log("PushNotification.register failure: failure parameter not a function"); - return - } +// Call this if you want to show toast notification on WP8 +PushNotification.prototype.showToastNotification = function (successCallback, errorCallback, options) { + if (errorCallback == null) { errorCallback = function () { } } - cordova.exec(successCallback, errorCallback, "PushPlugin", "showToastNotification", [options]); + if (typeof errorCallback != "function") { + console.log("PushNotification.register failure: failure parameter not a function"); + return } + + cordova.exec(successCallback, errorCallback, "PushPlugin", "showToastNotification", [options]); +} + // Call this to set the application icon badge PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) { if (errorCallback == null) { errorCallback = function() {}} @@ -66,7 +66,7 @@ PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallb //------------------------------------------------------------------- -if(!window.plugins) { +if (!window.plugins) { window.plugins = {}; } if (!window.plugins.pushNotification) { @@ -75,4 +75,4 @@ if (!window.plugins.pushNotification) { if (typeof module != 'undefined' && module.exports) { module.exports = PushNotification; -} \ No newline at end of file +}