React-native-firebase: How to remove notification on Android

Created on 25 Jul 2018  路  10Comments  路  Source: invertase/react-native-firebase

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);

Most helpful comment

@sidferreira use removeDeliveredNotification it's working for me

All 10 comments

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 I tried it and cancelNotifications didn't removed it...

@sidferreira use removeDeliveredNotification it's working for me

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

removeDeliveredNotification and removeAllDeliveredNotifications working for me

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

@LorandP firebase: 6.4.1

any update?

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rewieer picture rewieer  路  51Comments

umang-simform picture umang-simform  路  77Comments

OleksandrKucherenko picture OleksandrKucherenko  路  46Comments

jasan-s picture jasan-s  路  137Comments

neverlan picture neverlan  路  47Comments