skip to Main Content

I’m trying to update the notification count to 0 once the app is opened but I couldn’t find any relevant methods to update the badge count in @react-native-firebase/messaging package. Is there any possible way to update the notification count inside the app?

This is my listener

messaging().onNotificationOpenedApp(async (remoteMessage) => {
    console.log(remoteMessage);
})

Are there any methods provided by rnfirebase package to set the badge count inside the app? If there then that would be a great help 😊

2

Answers


  1. Chosen as BEST ANSWER

    I've used the below package to solve this problem

    react-native-push-notification
    

    Here's the code for it,

    import PushNotification from "react-native-push-notification";
    PushNotification.setApplicationIconBadgeNumber(0);
    

    This will reset the badge count to 0 once you open the app, You can also set the count as you want dynamically and it will get updated.


  2. import firebase from ‘react-native-firebase’;

    using code:
    firebase.notifications().removeAllDeliveredNotifications();
    or:
    firebase.notifications().removeDeliveredNotification(notificationId);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search