Skip to content

[Bug]: Badge counter keeps incrementing across notifications despite OneSignal.Notifications.clearAll() being called on every app foreground #1657

@anastely

Description

@anastely

What happened?

When using the Increase badge model (badge_inc: 1 in each push payload), the iOS icon badge keeps accumulating across notifications even though OneSignal.Notifications.clearAll() is called on every relevant trigger (app foreground, notification tap).

The next push after a reset is supposed to arrive with badgeNumber: 1, but instead arrives with badgeNumber: N+1, where N is whatever the counter was before reset.

Based on PR #1649, clearBadgeCount:fromClearAll: should explicitly zero ONESIGNAL_BADGE_KEY. That fix is present in 5.4.2+, but the bug still manifests end-to-end.

Steps to reproduce?

1- Fresh install, log in, call OneSignal.login(userId).
2- Send notification from dashboard with badge type Increase +1.
3- Icon shows 1 ✓
4- Foreground the app (or tap the notification). JS calls:
OneSignal.Notifications.clearAll()
Background the app (no user-initiated notification interaction needed).
5- Send notification, with the same Increase +1 payload.
6- Icon shows 2 ❌ — expected 1.

What did you expect to happen?

Per PR #1649's fix and the documented behavior of clearAll(): after OneSignal.Notifications.clearAll() is called, the next Increase +1 push should result in aps.badge: 1, not aps.badge: N+1.

OneSignal iOS SDK version

5.5.0

iOS version

18

Specific iOS version

Environment
react-native-onesignal: 5.4.3
OneSignalXCFramework: 5.5.0
React Native: 0.79.0
iOS: 26.4|.1 (also reproduced on iOS 18 simulator)

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions