iOS app icon badge count won't update
Describe the bug After receiving a chat notification, the iOS app icon badge count shows the number of unread messages. But sometimes it won't get updated when you actually read the message by going into the channel that the message has been sent.
Dev environment info (please complete/provide the following information):
- stream-chat-react-native 5.3.1
- react-native 0.67.3
- Device iOS 16.0.2
To Reproduce
- Receive a new message on a device when the app is running in the foreground or in the background. (App should be running)
- Without reading the message by going into the channel, see that the badge icon count got updated to reflect the unread count.
- Go into the channel where the message has been sent.
- Go to device's home screen and check your badge count on your app icon. It won't be updated.
Expected behavior Badge icon should get updated to reflect the new unread count (if it's zero it should get cleared out)
Additional context I found out that if you follow the steps above but receive the push notification when the app is killed (so it's not running in the foreground or in the background), the problem won't occur and the badge count will be updated.
Hey @semihcihan,
Please clear the badge count once the app is opened like below. This a good practice to do.
function App() {
useEffect(() => {
const clearBadge = async () => {
await notifee.setBadgeCount(0);
};
clearBadge();
}, []);
// Rest of your application
}