From 26cdbd6e17be62633a6942a77d94177dd96d2c06 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 26 Feb 2026 18:45:11 -0800 Subject: [PATCH] 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. --- .../OneSignalNotifications/OSNotificationsManager.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m index 698187b8d..95e29d101 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m +++ b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m @@ -801,6 +801,8 @@ + (void)clearBadgeCount:(BOOL)fromNotifOpened fromClearAll:(BOOL)fromClearAll { return; } + [OneSignalBadgeHelpers updateCachedBadgeValue:0 usePreviousBadgeCount:false]; + if (@available(iOS 16.0, *)) { [[UNUserNotificationCenter currentNotificationCenter] setBadgeCount:0 withCompletionHandler:^(NSError * _Nullable error) { if (error) {