evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

FCM Event instances are not clearing while removing the component from react-native-router-flux Actions route stack #988

Open prasanthyejje opened 6 years ago

prasanthyejje commented 6 years ago

I am Using FCM.getInitialNotification().then((notif) => this.getInitialNotificationFunction(notif)); this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => function(Notif) Both FCM Methods are executing multiple time.

Issue Explanation : I Closed My App By Clicking Device Hardware Back Button and Again I opened App By Clicking On The App Logo From Home Screen Of Device. here if I am Getting A FCM Notification Both Methods( FCM Method Mentioned Above) Are Executing Multiple TImes. If I close The App 3 Times Then FCM methods Are Executing 3 Times, If I Do This Process 4 times Then Methos Executes 4 Times.

And I Am Using react-native-router-flux For Navigation. When User Clicks Hardware Back Button I am Removing The All App Components(Screens) From react-native-router-flux Actions Stack(It Means When User Open The App, App Starts From The Splash Screen Component.) @evollu Help Me On This.

Environment

  1. Application Target Platform: Android OS

  2. Development Operating System: React-Native With Redux

  3. React Native version: react-native-cli: 2.0.1 react-native: 0.50.3

  4. RNFirebase Version: "react-native-fcm": "^11.2.0",

evollu commented 6 years ago

can you save the handler in global/module scope and check if the handler exists when you init the component?