dpa99c/cordova-plugin-firebasex

setBadgeNumber not working

michelsondan opened this issue · 8 comments

I am trying to set badge with my app logic, and it is not working. it's reseting the current badge.

` window.FirebasePlugin.setBadgeNumber(myCount, function () {
alert('success')
},
function (err) {
alert(err)
})

the function is running and display the alert 'success' on done event, but the badge is not set to my request number.

Please try building & running the example project to eliminate the cause of issue being in your own code.

If you are able to reproduce the issue in the example project, please complete the issue template to provide full details of the issue such as affected platform/version, etc.

I have tested it also with example project.
I see in log, that it is increment, but no badge number on app icon.
after sending push notification, I see the badge number set by system,
but after click on the button "Increment badge number", the badge is disappeared.

Screenshot_2019-08-30-15-52-52-166_il homely mls app
IMG_20190830_155449

Tested on Android Redmi Note 4
Android system NRD9OM 7.0

Thank You!

OK, thanks for the info, I will add to list for investigation

Upon investigation, the library used by this plugin to set the badge number on Android will not work on Android 8 and above.
As stated here, there's no way to programmatically set the badge number on Android 8+ without sending/displaying a notification.

Therefore I'm going to remove setBadgeNumber() and getBadgeNumber() from the Android implementation and make them iOS-only methods.

What is the logic of this? lot of time users entering to app by ignoring the popup notification, and the app should have the way to change the badge icon by internal logic that depend on user action.
this is bad.
must be a way.
Are all plugins not supporting badge?

As the StackOverflow post I've referenced makes clear, there is no way to modify the badge icon count on Android 8 and above without displaying a notification.
However if you think there's a way to do this, please feel free to implement it and make a pull request to add the functionality to this plugin.

This StackOverflow post don't seem to be Official answer.

ShortcutBadger does work on a subset of Android devices and this change has broken existing uses of this plugin.

Surely it would be better to leave the Android functions in place while updating the README to explicitly say that is not supported on all Android devices?