Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Badge Counter not resetting properly #527

Open
1 task done
gadzilka opened this issue Aug 2, 2022 · 3 comments
Open
1 task done

[Bug]: Badge Counter not resetting properly #527

gadzilka opened this issue Aug 2, 2022 · 3 comments

Comments

@gadzilka
Copy link

gadzilka commented Aug 2, 2022

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

  • I agree to follow this project's Code of Conduct
@jkasten2
Copy link
Member

jkasten2 commented Aug 2, 2022

@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.

@gadzilka
Copy link
Author

gadzilka commented Aug 3, 2022

Was this value also 0 on 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

@sainecy
Copy link

sainecy commented Nov 8, 2024

@gadzilka @jkasten2

I encountered the same issue in a native iOS app without using Unity. The problem stemmed from incorrect app group configuration. To resolve this, ensure that you're using the recommended app group, which should be added to both the OneSignalNotificationServiceExtension and the main target of your app.

If you're using a custom name for your app group instead of the recommended one, make sure this is reflected in the info.plist files for both targets. For more details, refer to OneSignal's documentation under the "Optional instructions to setup custom App Group Name" section here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants