evollu / react-native-fcm

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

getInitialNotification is called on every dev "Reload" after opening a notification #1020

Open BatDroid opened 5 years ago

BatDroid commented 5 years ago

react-native : 55.1 react-native-fcm: 16.1.0

whenever i open the app from notification (wether the app had been in background or not Running) and then reloading the app in dev mode the getInitialNotification is called and this brings bugs to me in dev mode since based on the notification i navigate user to a screen.(by react-native-router-flux) after opening the notification whenever i press Reload (to refresh the app) getInitialNotification is called with the same notification object. i've tried removeAllDeliveredNotification but it didn't fix the problem. it is in both ios and android

evollu commented 5 years ago

where do you call getInitialNotification?

BatDroid commented 5 years ago

@evollu at index.android.js/index.ios.js before outside the component. but i think this is related to the first bullet point of here. i wish there was a way to fix this or ill have to keep the notifications in a database.

evollu commented 5 years ago

so the problem only happens when you open the app though notification and hit cmd+R to reload JS? sounds a rare use case to me and shouldn't happen in production because you can't reload the app

BatDroid commented 5 years ago

yes, but unfortunately it happens in my app. my app is the type which user usually opens it when receives push notification and i have implemented codepush in my app. so the scenario (which is not rare) is user opens the app via push notification and then receives a codepush Update and then the js reloads and now there is a problem!

evollu commented 5 years ago

There are a couple ways may works

BatDroid commented 5 years ago