phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.32k stars 1k forks source link

setApplicationBadgeIconNumber set in foreground status #680

Open sathiyaraj45 opened 8 years ago

sathiyaraj45 commented 8 years ago

Hi, The following code i write to ios badge icon number set logic. while my app is active status meands badge icon number is set. When remove active status means not set badge icon number.

function onNotificationAPN (event) { localStorage.setItem("push_id",event["url-args"]);

if ( event.alert ) {
    //navigator.notification.alert(event.alert);        
}
if ( event.sound )
{
    var snd = new Media(event.sound);
    snd.play();
}

if ( event.badge )
{
  //  alert('badge')
    var badgeNumber = Number(localStorage.getItem("badge")) + 1;
    localStorage.setItem("badge",badgeNumber)
    if(event.foreground == false) {
    window.plugins.pushNotification.setApplicationIconBadgeNumber(successHandler, errorHandler, badgeNumber);
    } else {
        window.plugins.pushNotification.setApplicationIconBadgeNumber(successHandler, errorHandler, badgeNumber);
    }
}

}