Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
firebase.notifications().OnNotificationOpen多次调用_Firebase_React Native_Firebase Cloud Messaging - Fatal编程技术网

firebase.notifications().OnNotificationOpen多次调用

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

我调用了firebase.notifications().OnNotificationOpen on componentDidMount并在componentWillUnmount()上删除它,但当应用程序从后台删除时,它似乎从未将其删除,因为它已注册多次。下面是我使用的代码,让我知道我做错了什么

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