cordova-plugin-push-notification icon indicating copy to clipboard operation
cordova-plugin-push-notification copied to clipboard

How to prevent zeroing the badge when the application did become active ?

Open nashfive opened this issue 9 years ago • 5 comments

It seems that the plugin automatically resets the badge to zero each time the app becomes active (at least on iOS). How can I prevent this behavior if I want to keep the badge at its current value even if the app becomes active ? A typical use case would be to handle a badge counter of unread messages (in the same manner than the Mail.app).

I don't want to modify and keep an out-of-sync version of the native code in my project repository that might break each time I update the plugin. Could it be possible to benefit from the "resume" device event in the JS layer and reset the badge here only if needed ?

nashfive avatar Jun 23 '15 11:06 nashfive

@nashfive It is a bug in Plugin..!!!

kumaresan-cgvak avatar Jul 24 '15 12:07 kumaresan-cgvak

@kumaresan-cgvak I don't think it is a bug. It makes sense to reset the badge each time the app becomes active, but when you need to avoid it, it's hard to come up with a workaround.

nashfive avatar Jul 24 '15 12:07 nashfive

@nashfive if the App developer wish to reset during this scenario, then he could reset it by using "pushNotification.setApplicationIconBadgeNumber(successCallback, errorCallback, "0");" during app resume status. Which adds more flexibility to developer.

kumaresan-cgvak avatar Jul 24 '15 12:07 kumaresan-cgvak

@kumaresan-cgvak I agree... I should make a pull request, but I am not even sure that this is the official cordova plugin for push notifications...

nashfive avatar Jul 24 '15 13:07 nashfive

@nashfive I have made a pull request already. so, the issue could be resolved by merging the Pull request #2 that i have made.

If we use npm, then this plugin is used by Cordova.

kumaresan-cgvak avatar Jul 24 '15 13:07 kumaresan-cgvak