-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getInitialNotification not working #3964
Comments
Stop using "react-native-splash-screen": "^3.2.0", Switch to react-native-bootsplash Search issues and pull requests for "react-native-splash-screen" you'll see |
Dear @mikehardy |
On the plus side, bootsplash has a sweet command line interface to generate the .storyboard file you need to migrate to anyway, with screenshots even. It was a pleasant migration, which is not a thing I say often. Cheers |
Dear @mikehardy |
Is there an specific place where I should call |
@ghasemikasra39 I called it in App.tsx useEffect(Did mount equivalent). |
messaging().getInitialNotification().then(this.handleSelected);
handleSelected = async remoteMessage => {
const notification = JSON.parse(remoteMessage.data.message);
switch (notification.type) {
case NOTIFICATION_TYPE_ONE:
navigation.navigate('screen1', {
data: notification.data,
});
break;
case NOTIFICATION_TYPE_TWO:
navigation.navigate('screen2', {
data: notification.data,
});
break;
}
}; I am calling |
@ghasemikasra39 |
Is there a way to test this on simulator somehow ? It's extremely difficult to make small changes, then creating a build and install it on real device. I cannot debug or log something to find out where the problem is |
If you are on android it should work on simulator, debug mode should work fine. But in iOS there is no other way to test than on a real device. |
I cannot test it on a simulator, because I have to close the app to test |
I made it work by calling it at a higher level in the dom tree, right after the |
Hmm.. I haven't tested that scenario myself. Maybe it is due to the debug mode build? |
I created standalone apk and running on real device in release mode and facing this delay |
I created this question. In this question, you can find the latest update on my issue. I am still struggling with this issue. |
Hello 👋, to help manage issues we automatically close stale issues.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@ghasemikasra39 Did you resolve your problem? |
I tried the below changes and it worked in android, haven't checked in IOS yet
change in AndroidManifest.xml
|
strongly recommended to use react-native-boot-splash, it handles the intent extras for you so that's not needed |
Push notification does not give call back if there are multiple notifications in the notification console and when one notification is already clicked then clicking on another notification from the notification tray after closing the app does not call any notification life cycle method. Let's say there are 5-6 notifications in the console, we click on one of the notification which opens up the app and works as expected and calls the related methods. After that when we close the app and then click on another notification from the notification console then it does not call any notification method. I am using "react-native": "0.61.4", and "@react-native-firebase/messaging": "^7.4.2", |
Hello 👋, to help manage issues we automatically close stale issues.
|
Thanks a lot. it worked |
Use react-native-boot-splash |
This helped me #4005 |
I was able to solve this problem, helping me with the notifee. I work with React Native and this library can listen to the events of your notifications. |
Hi @RishavKumar-3796, I am facing the same issue, When there are multiple notifications, if i close the app and click on notification, Data is empty. Kindly let me know if you had any solutions/ workarounds. Thanks. |
still not working to me |
messaging().onNotificationOpenedApp called even when app killed + i got fcm notification?? ( Android) |
its work for me thank you 😁👍 |
hi i have created nested navigation how can is use this when i am using drawer screen it is givng error // function for handling log out
}; // function for showing logout modal // function for hiding logout modal // Logout Functionality Ends********// const currentUserName = useSelector(state => state.user.name);
); const HomeDrawer = ({navigation}) => { useEffect(() => { useEffect(() => { // api call for reading all notification const notificationIcon = () => { // get current user role
); const StackNavigator = () => {
}, []);
); export default StackNavigator; const styles = StyleSheet.create({ |
Hi @Haseeba393
|
@keshavsharma0712 brother according to documentation, if the app is not launched by notification then you will receive null in this promise or if you relaunch app then it will be removed as well in this case again you will receive null. |
If you are using notifee along with RN firebase, you can use their listener while app mounting,
|
^^ For me, both of this methods are not working. "@react-native-firebase/messaging": "18.3.0", |
facing this issue. can anybody help? |
@thisisashukla @khushbujilka22 can you provide reproduce able error repo? Also did you try to use await and async? |
@Haseeba393 here is my useEffect function
i am getting |
@thisisashukla in which file did you write this use effect? Also are you using any bootsplash package for splash screen? |
i am using expo-splash-creen. i have written this useEffect in App.js |
Your application is based on React Native Expo or React Native CLI? |
react native expo |
testing on real device or emulator? |
@thisisashukla were you able to make it work ? |
Yes |
Can you tell me what solution you applied please I am facing the same issue getInitialNotification is null I have tried all the available suggestions. |
We are running into the same issue as well. This is on iOS physical device, and Edit
|
Those functions moved to https://notifee.app/ library so you will have to use notifee Read this: https://rnfirebase.io/messaging/usage#background--quit-state-messages |
Ah that makes sense. I did more testing. It seems like for prod build, what worked was not In the end we are going with:
|
Using
|
At first I switched from Then, I read this part of @tao-qian comment.
I tried it and it worked! Note: I encountered this issue on Android. |
This works for me
|
Issue
The
messaging().onNotificationOpenedApp
works perfectly fine, when the app is open but is in the background.The
messaging().getInitialNotification()
however, is not working as expected when the app is closed. Tapping on the notification will just open the app.Project Files
Javascript
Click To Expand
package.json
:firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:AppDelegate.m
:Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:7.1.0
Firebase
module(s) you're using that has the issue:getInitialNotification
TypeScript
?3.9.5
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: