Created
November 6, 2014 22:30
-
-
Save calendee/f3437964f8497eb30da3 to your computer and use it in GitHub Desktop.
PushWoosh Badge Process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Outside of angular, need to listen for `push-notification` event. | |
document.addEventListener('push-notification', function(event) { | |
// Get access to angular to report event. | |
var body = document.getElementsByTagName("body")[0]; | |
var appController = angular.element(body).scope(); | |
appController.processPushnotification(event); | |
}); | |
// In my service, determine what the badge count should be and then update it | |
var updateBadge = function(event) { | |
var badgeCount = 0; | |
MessagesService.getNewMessageCount().then( | |
function(badgeCount){ | |
window.plugins.pushNotification.setApplicationIconBadgeNumber(badgeCount); | |
} | |
); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment