react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

Android removeDeliveredNotification(id) not working

Open king804 opened this issue 7 years ago • 12 comments

Hi , i have an issue about remove delivers notification, because i develop new feature "remove message". Therefore, i want to remove notification by unique id.

the notification id base on fcm curl send api return. (https://fcm.googleapis.com/fcm/send)

The android can't remove notification by id , but remove all is fine.

Backend curl post body let body = { to: push_token, notification:{ title: user_name, body: content, sound: "default", icon: "notify", badge: 1, }, data: { custom_notification: { show_in_foreground: false, badge: 1, priority: "high", content_available: true, } }, content_available: true, priority: "high" }

React Native Code async componentDidMount(){ firebase.notifications().removeDeliveredNotification('0:1544884734101699%e81a54d1e81a54d1'); }

"react-native": "0.57.0", "react-native-firebase": "^5.1.0",

king804 avatar Dec 16 '18 01:12 king804

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 13 '19 04:01 stale[bot]

I have the same issue when app in background and receive notification and try to remove it by messsageId. I found out that there is id always 0 and generated tag by FCM. image

MGaburak-eleks avatar Jan 21 '19 10:01 MGaburak-eleks

I have the same problem. Only this works: firebase.notifications().removeAllDeliveredNotifications()

Have you tried with notification.android.setAutoCancel( true ); ? I have tried it with this also but it doesn't do anything

LorandP avatar Jan 29 '19 15:01 LorandP

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 26 '19 17:02 stale[bot]

From react-native-firebase 5.1.0+ you can apply this solution and it will work.

if(Platform.OS === 'android' && typeof notification.android.tag === 'string'){
       let tag: string = notification.android.tag;
       Firebase.notifications().android.removeDeliveredNotificationsByTag(tag);
   } else {
       Firebase.notifications().removeDeliveredNotification(notification.notificationId);
   }

LorandP avatar Feb 27 '19 09:02 LorandP

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 27 '19 10:03 stale[bot]

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

stale[bot] avatar Apr 24 '19 10:04 stale[bot]

@LorandP Hey, I have the same issue when i receive a notification "when app killed" and click to open it, it's opened very well and navigate me to "Notifications Screen" But in every time after I open the app without click to any notification it navigates me to "Notifications Screen", SO How can I remove the previous notification, I'm Tried this But didn't work

async componentDidMount() {
    BackHandler.addEventListener("hardwareBackPress", this.backPressed);

    this.notificationInitListener = await firebase
      .notifications()
      .getInitialNotification()
      .then(notificationOpen => {
        if (notificationOpen) {
          console.log(notificationOpen);
          setTimeout(() => {
            this.props.navigation.navigate("Notifications");
          }, 2000);
        }
        console.log("1---OPEND");
        firebase.notifications().removeAllDeliveredNotifications();
        console.log("1---OPEND-After");
      });
}

anastely avatar Jul 24 '19 15:07 anastely

I have the same problem. Only this works: firebase.notifications().removeAllDeliveredNotifications()

Have you tried with notification.android.setAutoCancel( true ); ? I have tried it with this also but it doesn't do anything

My app worked with SetAutoCancel(true) !!!!

joshcho96 avatar Sep 05 '19 06:09 joshcho96

** if (Platform.OS === "android") { notification.android.setAutoCancel(true) } firebase.notifications().removeDeliveredNotification(notification.notificationId) **

worked for me

pankajtft avatar Feb 10 '20 09:02 pankajtft

any update ? im using "react-native-firebase": "^5.6.0", and "react-native": "0.61.5", but removeDeliveredNotification isn't work for me ! i also set .android.setAutoCancel(true) but it didn't help ! plz help me

hanzoow avatar Jul 08 '20 05:07 hanzoow

i didnt see removeDeliveredNotification from the lib

fukemy avatar Aug 21 '23 02:08 fukemy