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

How do you set the badge count programmatically? #63

Closed
masterkrang opened this issue Jul 17, 2016 · 3 comments
Closed

How do you set the badge count programmatically? #63

masterkrang opened this issue Jul 17, 2016 · 3 comments

Comments

@masterkrang
Copy link

masterkrang commented Jul 17, 2016

Since it isn't possible (as far as I know) to get/set the badge count programmatically in OneSignal, I've used this library https://github.com/zo0r/react-native-push-notification#ios-only-methods and this function: PushNotification.setApplicationIconBadgeNumber(number: number) to reset the badge count in my application in addition to using OneSignal.

However, when I make the call to PushNotification.setApplicationIconBadgeNumber(number: number) OneSignal will still increment the badge count continuously, not respecting this badge count.

How to reproduce:

  • turn off OneSignal badge clearing: OneSignal_disable_badge_clearing in Info.plist
  • Send a notification from OneSignal Dashboard
  • Open app, the badge icon is now cleared due to the call to PushNotification.setApplicationIconBadgeNumber(number: number)
  • Send another push notification from OneSignal Dashboard
  • Note the badge count on the app icon was never really set to 0 in OneSignal, it was incremented

Question: How do I reset the badge count so that OneSignal doesn't continuous increment the badge count each time the push comes in.

Note: I believe what is happening here is that when the badge count is set to 0 in the client, OneSignal is not made aware of it in the cloud, so it keeps on incrementing the number. What is needed is a way to tell OneSignal the the badge count has been set to 0.

Related: #62

cc @avishayil

@JKalash
Copy link

JKalash commented Aug 17, 2016

Related: Inconsistent Badge Count iOS.

@Nightsd01
Copy link
Contributor

For future reference, the OneSignal SDK will not touch the badge count unless:

Your push notification contains ios_badgeCount and ios_badgeType parameters.

Your info.plist file contains OneSignal_disable_badge_clearing key. This controls how the OneSignal SDK will handle clearing badge count when the user opens the app. If set to false, the SDK will not touch the badge count and it is up to your app to clear the badge count.

Instead of using a third party SDK to set the badge count, all you have to do is called `UIApplication.setApplicationIconBadgeNumber("0") to clear the badge count.

Closing this issue due to inactivity, please feel free to respond if you are still encountering this issue.

@dungnguyen10989
Copy link

@Nightsd01 where can I call UIApplication.setApplicationIconBadgeNumber("0") from UI of react-native ?

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

5 participants