Skip to content

fix: badge count not resetting when notifications are cleared#1649

Open
nan-li wants to merge 1 commit intomainfrom
fix/badge_clearing_cache
Open

fix: badge count not resetting when notifications are cleared#1649
nan-li wants to merge 1 commit intomainfrom
fix/badge_clearing_cache

Conversation

@nan-li
Copy link
Contributor

@nan-li nan-li commented Feb 27, 2026

Description

One Line Summary

Reset cached badge count value when notifications are cleared.

Details

Motivation

When using badge type "Increase", the cached badge value (ONESIGNAL_BADGE_KEY) in shared UserDefaults was not explicitly reset to zero in clearBadgeCount:fromClearAll:. If the swizzled badge setter did not fire, the NSE would read the stale cached value and increment from it, producing an incorrect badge count.

Scope

badges

Testing

Unit testing

Manual testing

Tested on iPhone iOS 26.3

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

When using badge type "Increase", the cached badge value
(ONESIGNAL_BADGE_KEY) in shared UserDefaults was not explicitly
reset to zero in clearBadgeCount:fromClearAll:. If the swizzled
badge setter did not fire, the NSE would read the stale cached
value and increment from it, producing an incorrect badge count.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant