ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
518 stars 583 forks source link

feat: `getBadgeCount` and `setBadgeCount` methods for notifications #228

Open rossholdway opened 4 years ago

rossholdway commented 4 years ago

Feature Request

Describe the Feature Request

iOS (and some Android) notification payloads often contain the number of unread notifications, however currently this value can't be used. Support setting and getting the notification badge count by implementing getBadgeCount and setBadgeCount methods.

I notice this feature has been mentioned in other issues too (#1301 ionic-team/capacitor#837 etc). It is also currently a supported feature of the phonegap push plugin. See push.setApplicationIconBadgeNumber and push.getApplicationIconBadgeNumber at https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md

Platform Support Requested

Describe Preferred Solution

Add getBadgeCount and setBadgeCount methods

scriptPilot commented 4 years ago

Is there any workaround with the current LocalNotifications plugin?

rossholdway commented 4 years ago

Unfortunately not that I can see from the Capacitor local notifications docs

scriptPilot commented 4 years ago

@rossholdway - Did you find another solution? I did not find proper documentation how to use the Cordova plugins unfortunately ... (see https://github.com/ionic-team/capacitor/issues/2195).

rossholdway commented 4 years ago

@scriptPilot No, sorry haven't found another way to do this currently.

dminkovsky commented 4 years ago

This looks promising: https://github.com/katzer/cordova-plugin-badge

Haven't tried it yet, but intend to.

nelsonjimartinez commented 4 years ago

Los problemas etiquetados con solicitud de función se cierran, pero se realiza un seguimiento de las reacciones para medir el interés.

Tenga en cuenta que esto no es compatible oficialmente con Android. Solo es posible en unos pocos proveedores. Hay una biblioteca de terceros para manejar los llamados shortcutBadger y no planeamos agregar esa dependencia solo para esta función, así que creo que encaja mejor en un complemento de terceros

https://developer.android.com/training/notify-user/badges

christian-forgacs commented 2 years ago

Any update for this feature request..? Because if anybody remove a notification from notification center the badge count will not update with Badge.set from Badge plugin because it isn't in foreground and a background task for this is not optimal.

Alternatively please add a new event for Local Notification Plugin if an notification is removed so we can listen on it on an background task.

pivko420 commented 1 year ago

If anyone is still looking for solution, take a look at this plugin: https://github.com/capawesome-team/capacitor-plugins/tree/main/packages/badge