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

How to remove notification on Android

Open hoangvuanhdevelopervn opened this issue 8 years ago • 11 comments

I use firebase to push notification, it's work fine but have two problems in my app:

  1. I can't swipe to remove notification, must click to run app to remove it.
  2. I must click each notification to remove it, and i think it's so bad. So how to swipe to remove a notification and when click one, all notification will remove?

That is my code:


 // android settings
  notification.android.setColor(theme.primaryBackground);
  notification.android.setColorized(true);
  notification.android.setOngoing(true);
  notification.android.setPriority(
    firebase.notifications.Android.Priority.High
  );
  notification.android.setSmallIcon('subiz_icon');
  notification.android.setVibrate([1000, 1000, 1000, 1000, 1000]);
  notification.android.setLights(0xff00ff00, 3000, 3000);
  notification.android.setChannelId('notification');
  notification.android.setAutoCancel(true);

  return firebase.notifications().displayNotification(notification);

hoangvuanhdevelopervn avatar Jul 25 '18 10:07 hoangvuanhdevelopervn

Welcome @hoangvuanhdevelopervn 🎉

You can call either of these to cancel a ongoing notification: https://rnfirebase.io/docs/v4.3.x/notifications/reference/Notifications#cancelNotification or https://rnfirebase.io/docs/v4.3.x/notifications/reference/Notifications#cancelAllNotifications

Additionally you can use the new functionality to cancel notifications by a tag:, see this PR that implemented it as it's currently still undocumented: https://github.com/invertase/react-native-firebase/pull/1058


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

Salakar avatar Jul 26 '18 17:07 Salakar

@Salakar I tried it and cancelNotifications didn't removed it...

sidferreira avatar Aug 14 '18 00:08 sidferreira

@sidferreira use removeDeliveredNotification it's working for me

Agoujil2saad avatar Dec 02 '18 14:12 Agoujil2saad

removeDeliveredNotification is not working for me on react-native: 0.57.7 and firebase 4.3.8 Only removeAllDeliveredNotifications works

LorandP avatar Jan 29 '19 15:01 LorandP

removeDeliveredNotification and removeAllDeliveredNotifications working for me

cuongtora1996 avatar Mar 21 '19 11:03 cuongtora1996

@cuongtora1996 What version of firebase have you tried it on?

LorandP avatar Mar 21 '19 13:03 LorandP

@LorandP firebase: 6.4.1

cuongtora1996 avatar Mar 22 '19 03:03 cuongtora1996

any update?

lyseiha avatar May 26 '20 03:05 lyseiha

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

removeDeliveredNotification and removeAllDeliveredNotifications working for me

Hi. I am struggling with removeDelieveredNotification(). It requires array of identifiers to remove the specific notification. What did you write for identifiers, I am still not understanding

obito2502 avatar Jan 13 '21 10:01 obito2502

how to call removeDeliveredNotification?

fukemy avatar Aug 21 '23 02:08 fukemy