This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I added the init parameter "clearBadge" which is treated the same as the others and stored to SharedPreferences. If it's set, the app sets the badge number to 0 on init. Also, when a notification is receviced, the badge number is immediately cleared in order to leave the config of the badge through notification parameter untouched. Now when a notification is recevied, the badge is cleared before the notification content is processed, therefore any badge numbers set in the notification will be respected. I tried to implement this as close to the iOS implementation as possible.
Related Issue
#999
Motivation and Context
Even though I was not setting the Badge Number, it was some times (on specific devices) appearing out of nowhere after init. I wanted to have a way to make sure that the Badge Number is not shown by accident.
How Has This Been Tested?
I manually added a badge number through the "setApplicationBadgeNumber" function. Then I restarted the app causing the init function to trigger. The badge number was immediately cleared. I also set the BadgeNumber after init and sent a notification that had no badge number arguments. The badge number was also cleared immediately.
I only did manual tests on Android devices.
There shouldn't be any unexpected side effects on other code.
Screenshots (if appropriate):
Types of changes
Checklist: