From 8377bc4d8b5b1b13838057995546d47cfe34236f Mon Sep 17 00:00:00 2001 From: Simon MacDonald Date: Sat, 27 Jun 2015 22:29:07 -0400 Subject: [PATCH] Issue #18: iOS badge number --- www/push.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/www/push.js b/www/push.js index 8462789df..525a7bb57 100644 --- a/www/push.js +++ b/www/push.js @@ -70,6 +70,26 @@ PushNotification.prototype.unregister = function(successCallback, errorCallback, exec(successCallback, errorCallback, "PushNotification", "unregister", [options]); }; +/** + * 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 successCallback != "function") { + console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function"); + return + } + + cordova.exec(successCallback, errorCallback, "PushNotification", "setApplicationIconBadgeNumber", [{badge: badge}]); +}; + /** * Listen for an event. *