Skip to content

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

Closed

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

Activity

  1. nan-li commented on Jun 23, 2026

    @nan-li
    Contributor

    Hi @anastely thanks for the report,

    On iOS, "Increase" badges are tracked on-device by your Notification Service Extension (NSE), not on the server. The NSE keeps a running badge count in a shared App Group, and clearAll() resets that count back to zero. We confirmed clearAll() is correctly wired from React Native to the native SDK.

    The key requirement: the running count is only shared correctly if your main app and your OneSignalNotificationServiceExtension use the same App Group. The behavior you're seeing, increments work (1 → 2 → 3) but clearAll() never resets back to 1, is a sign that the two targets aren't sharing the same App Group, so the NSE keeps counting up while clearAll() resets a separate, unused count.

    Could you verify:

    1. The App Group capability is enabled on both the app target and the OneSignalNotificationServiceExtension target, with the identical identifier (e.g. group.<your_bundle_id>.onesignal), and included in both provisioning profiles.
    2. If you set the OneSignal App Group key in Info.plist, that it's present and identical in both targets' Info.plist.

    Setup steps for both targets are here: https://documentation.onesignal.com/docs/en/react-native-sdk-setup (see the iOS App Group steps).

    For a step-by-step checklist to confirm the App Group is shared on both targets, see https://documentation.onesignal.com/docs/en/confirmed-delivery#ios

    If you can share both .entitlements files and confirm the NSE is installed, we can pinpoint it quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions