katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.57k stars 1.76k forks source link

How can I remove the Red Circle marked on my App Icon after notification (iOS) ? #398

Closed ramsabarish closed 9 years ago

ramsabarish commented 9 years ago

I have successfully schedule the notification by this code .

window.plugin.notification.local.add({ title: eventName, message: description, date: schedule_now, smallIcon: 'ic_dialog_email', icon: 'file://img/smallLogo.png' });

But after this a Red Circle with a number appears on my App icon in iPhone. Even though I clear the notification on device, my App icon is marked with a Red Circle. How can I remove it once the user is notified with the event.

bayhall commented 9 years ago

Have you tried to use the Badge plugin: https://build.phonegap.com/plugins/1123

ramsabarish commented 9 years ago

No I haven't tried Badge plugin: https://build.phonegap.com/plugins/1123

ramsabarish commented 9 years ago

As soon as we tap on an App icon the badge for notification should be removed. So can you Kindly tell me have I missed any step that will remove the Badge. Well I don't have this issue on Android.

bayhall commented 9 years ago

If using PhoneGap Build - I'd recommend the plugin repository for the latest versions:

<gap:plugin name="de.appplant.cordova.plugin.local-notification" source="plugins.cordova.io" version="0.7.8" />   
<gap:plugin name="de.appplant.cordova.plugin.badge" source="plugins.cordova.io" version="0.6.1" />  

When you open your App, you can clear all badges after deviceready - you can clean up all badges using the Badge plugin:

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

Also, if the user clicks the notification you can setup a callback, and here you can manage the badge/s to be removed on an individual bases (more is documented in the plugin readme regarding sending a useful JSON object):

    window.plugin.notification.local.onclick = function (id, state, json) {
        cordova.plugins.notification.badge.set(-1) //to remove one badge
        alert("NOTIFICATION ID: " + id + " JSON:" + JSON.parse(json).youritem);
    }   
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!