question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: Updating badge number not working when app is in background or closed state.

See original GitHub issue

Hi there. I’ve problem with updating badge number. on iOS, appIcon badge number automatically updated everytime when I get push notification even the app is in background or closed. but on Android, appIcon badge number is only changed when app is in foreground and if the app is in background or closed state, I receive fcm push notification but the app badge icon is not automatically changed. I don’t want to go on with FCM.setBadgeNumber(), because if I call it in javascript code, it will not fired when app is closed or in background and it will not work too. So is there anyway to update badge number automatically when getting push notification even the app is closed on Android? Do I need to run kind of background service or task which calls FCM.setBadgeNumber() to achieve this? iOS is really working well and I want Android should working same as iOS. My message payload looks like this. message = { to: 'push token', data: { badge: 3 }, // for Android badge number and only works when app is alive. notification: { title: 'xxx', body: 'xxx', badge: 3 // for iOS badge number and this changes iOS app badge count even app is closed. } }; Thanks

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:10
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tawsifalamcommented, May 4, 2018

@shekharskamble I did that and it works only when the app is in foreground. It doesn’t update or show badge count when the app is in killed or background state.

0reactions
ajinkyap7commented, Jun 21, 2019

Hi @gitpayal ,

Thanks for the reply. At least the thread is still going 😃 Regarding the payload, we are using the following structure: { “data”: { “title”: “MESSAGE_TITLE”, “body”: “MESSAGE_BODY”, “badge”: “BADGE_COUNT<INT>” } }

In the above JSON, BADGE_COUNT is an integer so while sending the push notification, the actual badge count, for example 5, will be sent. This badge count is the current number that should be shown on the App Icon (or in the list after long-pressing the app icon from Android 8.0 onward)

We are also using Firebase Push Notifications in the application. Everything works well for iOS (payload is different though) but for Android the badge count doesn’t get updated the way it should.

Let me know how you implemented the badge count in your application. It may prove to be helpful.

Regards, AJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing badge count in Push Notifications with Expo in ...
This entails that changing the badge count while the app is in background cannot be ... setBadgeNumberAsync(number) , whereas for Android the only...
Read more >
Modify a Notification Badge | Android Developers
There are cases where badges don't make sense for your notifications, so you can disable them on a per-channel basis by calling setShowBadge( ......
Read more >
setting badge count when app is killed - Apple Developer
But my app is not showing badge count when app is in killed state and it is built in Released. (if it is...
Read more >
App doesn't show badge while is background or closed - MSDN
Knowing this, i put my code to receive PN in the MainApplication class in Android Project, however i am still not showing badge...
Read more >
awesome_notifications | Flutter Package - Pub.dev
Notifications could be created at any moment (on Foreground, Background or even when the application is terminated/killed). High trustworthy on receive ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found