Android removeDeliveredNotification(id) not working
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",
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.
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.

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
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.
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);
}
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.
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.
@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");
});
}
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) !!!!
** if (Platform.OS === "android") { notification.android.setAutoCancel(true) } firebase.notifications().removeDeliveredNotification(notification.notificationId) **
worked for me
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
i didnt see removeDeliveredNotification from the lib