evollu / react-native-fcm

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

unregistering Receiver on LocalBroadcastManager #939

Open karthikpala opened 6 years ago

karthikpala commented 6 years ago
  1. RN -0.52 , react-native-fcm - 11.3.1
  2. Using android emulator and nexus 5 with 7.1.1
  3. background and foreground

Awesome project @evollu 🥇 Kudos for your efforts 👍

Thought this might not be an issue but might be a reason for receiving push notifications twice in some cases. Please clarify. In the file FIRMessagingModule.java, registerMessageHandler() method, we are registering receiver on react context and not unregistering when app is unmounted. Can we create a @ReactMethod and call it to unregister the receiver from a higher order js component?

evollu commented 6 years ago

you can unregister it

let unregister = FCM.on(FCMEvent.Notification, ()=>{});
unregister(); // this unregisters listener
karthikpala commented 6 years ago

Please correct me if I am wrong, this unregisters listeners on the javascript end right? I am talking about the reciever we have created on the localbroadcastManager in android native code.

evollu commented 6 years ago

why do you want to unregister that?