Updating AppIconBadgeCount when app is not active (#android)
Is there a way to update applicationBadgeIconCount when app is not active (neither in foreground nor in background)
With iOS you can send a push notification and set the application badge number in there.
With Android, you will be able to once the current master is released. It make it possible to run code when a push notification is received even if your app isn't running.
Thanks will be waiting for that nice update
Any progress?
I believe this is supported, on both iOS and Android. Can we close?
Can you post gist with code example, pls?
Just follow the docs... PushNotification.setApplicationIconBadgeNumber
Work on iOS, not on Android
"react": "15.4.1",
"react-native": "0.38.0",
"react-native-push-notification": "2.2.1",
Test code
function resetBadge() {
AsyncStorage.setItem('pendingNotifications', JSON.stringify([]));
PushNotification.setApplicationIconBadgeNumber(10);
console.log('BADGE RESET');
}
Do you see an exception in logcat? It doesn't work on all android devices.
Android device 4.4.2 - dont work There is no exception in logicat
Android 6.0.0 emulator - dont work iOS 9 emulator - work iOS 10 emulator - work
It's likely that it won't work at all on an emulator (though I'm not 100% sure on that). Try it on a physical device.
Also, make sure you're not filtering out the exception in logcat by accident.
Did't work with stock Android or MIUI on real devices. Cant you write devices / launcher where it work?
working fine,
@manjeet-dobble can you provide code example and your react, react-native, react-native-push-notification version and Android device + version info, pls?
@klinkov actually my code is almost same as yours, but I am unable to update its count dynamically
What about other, android, device and packages versions?
Cannot get this working on any android device. RN 0.39, plugin version 2.2.1
Ok can get it working but only while the app is in the foreground. Number doesn't change when app is in the background or closed on Android.
Also looking for a solution to this. On iOS a scheduled notification without message is the way to do it, but I get an error when sending null as message here. No idea how it's usually done on Android.
I would actually prefer a separate method for it - how about introducing a scheduleApplicationIconBadgeNumberUpdate that takes a time and number?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.