react-native-fcm: Android: Updating badge number not working when app is in background or closed state.
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
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 10
- Comments: 22 (3 by maintainers)
@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.