【发布时间】:2019-05-15 20:39:49
【问题描述】:
我正在向我的应用发送多个通知。我想要实现的是,每当用户单击一个通知时,通知托盘中的所有通知都会消失。
我试过添加
notification.android.setAutoCancel(true)
只对一个通知(被点击的那个)起作用
我也试过了:
firebase.notifications().removeAllDeliveredNotifications()
没有任何作用。
我怎样才能做到这一点?
这是我的完整代码:
componentDidMount() {
firebase.notifications().removeAllDeliveredNotifications()
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
});
this.notificationListener = firebase.notifications().onNotification(async (notification) => {
// Process your notification as required
notification.android.setAutoCancel(true)
firebase.notifications().removeAllDeliveredNotifications()
}
async componentWillMount() {
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
});
this.notificationListener = firebase.notifications().onNotification((notification) => {
});
this.notificationDisplayedListener();
this.notificationListener();
}
【问题讨论】:
标签: react-native firebase-cloud-messaging android-notifications firebase-notifications react-native-firebase