Skip to content

Commit 26cdbd6

Browse files
committed
fix: badge count not resetting when notifications are cleared
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.
1 parent 3092003 commit 26cdbd6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ + (void)clearBadgeCount:(BOOL)fromNotifOpened fromClearAll:(BOOL)fromClearAll {
801801
return;
802802
}
803803

804+
[OneSignalBadgeHelpers updateCachedBadgeValue:0 usePreviousBadgeCount:false];
805+
804806
if (@available(iOS 16.0, *)) {
805807
[[UNUserNotificationCenter currentNotificationCenter] setBadgeCount:0 withCompletionHandler:^(NSError * _Nullable error) {
806808
if (error) {

0 commit comments

Comments
 (0)