Skip to content

Instantly share code, notes, and snippets.

@calendee
Created November 6, 2014 22:30
Show Gist options
  • Save calendee/f3437964f8497eb30da3 to your computer and use it in GitHub Desktop.
Save calendee/f3437964f8497eb30da3 to your computer and use it in GitHub Desktop.
PushWoosh Badge Process
// 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