katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.75k forks source link

iOS (v8) counter doesn't decrement unless notification is clicked #396

Closed huttj closed 9 years ago

huttj commented 9 years ago

The home screen icon counter/badge counts up for each notification that is deployed. However, clearing the notifications does not decrement the counter, as would be expected. The only thing that decrements the counter is tapping on the notifications.

Consequentially, the counter can be stuck at a non-zero number if any notifications are dismissed before they are tapped on.

How can I decrement the counter?

joshbuckley182 commented 9 years ago

I've also noticed this - I think it's a recent thing because I've not seen it before.

bayhall commented 9 years ago

I found using the de.appplant.cordova.plugin.badge plugin to manage badges (created by the same developer).

You can wipe all badges easily after deviceready:

cordova.plugins.notification.badge.clear();

Also, works with local-notification permission request (as this request badges, sounds, and banners, you don't need to request badges through the Badges plugin also).

    window.plugin.notification.local.hasPermission(function (blnHasPermissionGranted) {
        if (blnHasPermissionGranted == false) {
            //alert("no notification permissions")                   
            window.plugin.notification.local.promptForPermission();
        } else {
            //alert("notification permissions")
            cordova.plugins.notification.badge.clear();
        }
    });  

You can also manage the icon on an individual bases:

cordova.plugins.notification.badge.set(-1) for example.

stefanmdt commented 9 years ago

Which version are you using? In my case the badge is always "1", also if multiple notifications are deployed. As soon as I either click on one of the notifications or open the app via home screen icon, the badge disappears ...

huttj commented 9 years ago

I'm using 0.8.0dev.

katzer commented 9 years ago

The new 0.8.x release is a complete rewrite. If the issue still exists please reopen it.

You may also take a look into the new wiki.

Thanks!