[Bug]: Badge Counter not resetting properly
What happened?
After the badge counter is reset to 0 and a new push notification received with +1 on the badge, the old value is restored. Many of our customers report this issue to us from different apps.
Steps to reproduce?
1. Launch the app - bagde: 0
2. Receive a new push notification with +1 - bagde: 1
3. Receive a new push notification with +1 - badge: 2
4. Open the app - badge: 0
5. Receive a new push notification with +1 - badge: 3
What did you expect to happen?
Unfortunately, there are not many places in your code that can be debbuged. I tried to get more information from your Notification Extension.
In Step 5 before calling OneSignal.didReceiveNotificationExtensionRequest:
onesignalBadgeCount is 0 (this is the value from UserDefault associated with the app group)
bestAttemptContent.badge is 3 (the content of UNNotificationRequest)
after calling OneSignal.didReceiveNotificationExtensionRequest
onesignalBadgeCount is 3 (the badge counter also has the same value)
This means that your server send the wrong number for the badge counter. I can assume that something wrong happened in the app when you reset the badge counter and send the information to your server.
Unity version
Unity 2020.3.36f1
OneSignal Unity SDK version
3.0.3
Platform
iOS
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@gadzilka Thanks for reporting and digging in and providing these debugging details.
It seems the Notification Service Extension is running correctly as you were able to get debugging output from it.
In Step 5 before calling OneSignal.didReceiveNotificationExtensionRequest: onesignalBadgeCount is 0 (this is the value from UserDefault associated with the app group)
Was this value also 0 on step 3 from above as well?
When did you create your app on the OneSignal dashboard? The defaults for badges are different if it was created in 2018 vs something newer.
Was this value also
0on step 3 from above as well?
No, in step 3, after calling OneSignal.didReceiveNotificationExtensionRequest the value of onesignalBadgeCount is 2. Only 2 push notifications have been received so far.
When did you create your app on the OneSignal dashboard? The defaults for badges are different if it was created in 2018 vs something newer.
It was old app, it was created a long time ago. Should I test a new one? What to do with the old one?
Here are some additional logs from the main app in step 4 (user id and app id are hidden in logs):
applicationWillEnterForeground: onesignalBadgeCount is 2
applicationDidBecomeActive: onesignalBadgeCount is 2
DEBUG: OneSignal SessionManager attemptSessionUpgrade with entryAction: 1
DEBUG: OneSignal SessionManager attemptSessionUpgrade try UNATTRIBUTED to INDIRECT upgrade
DEBUG: OneSignal SessionManager sendSessionEndingWithInfluences with influences: ()
VERBOSE: HTTP Request (OSRequestBadgeCount) with URL: https://api.onesignal.com/players/<user id>, with parameters: {
"app_id" : "<app id>",
"badgeCount" : 0
}
applicationWillResignActive: onesignalBadgeCount is 0