firebase.notifications().OnNotificationOpen多次调用
我调用了firebase.notifications().OnNotificationOpen on componentDidMount并在componentWillUnmount()上删除它,但当应用程序从后台删除时,它似乎从未将其删除,因为它已注册多次。下面是我使用的代码,让我知道我做错了什么firebase.notifications().OnNotificationOpen多次调用,firebase,react-native,firebase-cloud-messaging,Firebase,React Native,Firebase Cloud Messaging,我调用了firebase.notifications().OnNotificationOpen on componentDidMount并在componentWillUnmount()上删除它,但当应用程序从后台删除时,它似乎从未将其删除,因为它已注册多次。下面是我使用的代码,让我知道我做错了什么 notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen
notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen: any) => {
console.log("onNotificationOpened", notificationOpen);
notificationOpen && notificationOpen.notification && notificationOpen.notification._data && notificationOpen.notification._data.extra && setTimeout(() => {
}, 500);
});
async componentDidMount() {
this.notificationOpenedListener =
firebase.notifications().onNotificationOpened((notificationOpen: any) => {});
}
componentWillUnmount() {
this.notificationOpenedListener();
}