-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Two notification when use firebase v6 with react-native-push-notification #3526
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
Comments
The two notifications arrive as the OS of your phone handles any Push notification which includes the notification tag. {
"notification": {
"title":"Test",
"body":"Test",
}
} The OS will present the user with this notification. Then either If you do not want your push notification to be handled by the OS, just send a data message without the notification tag. {
"data": {
"title":"Test",
"body":"Test",
}
} Here, you would additionally need to set the priority to high / contentAvailable to true when sending the notification // Required for background/quit data-only messages on iOS
contentAvailable: true,
// Required for background/quit data-only messages on Android
priority: 'high',
You can read more about that here: https://firebase.google.com/docs/cloud-messaging/concept-options For your questions 2: I'm currrently facing a similar issue there. |
Thanks @foxfl, it is now cleaner for me. Two notification problem fixed with "data" object. Still get null on launched app and trying to solve. What is the point of using notifications if I cannot solve this.. |
Sending message with "data" tag not solved probably. In the foreground state, app returns twice the message handler, so I see two notification from top;
|
Yeah, having a similar issue, described here #3514. I only send data messages and generate local messages through Are you sending through FCM console or through a SDK/REST? Because on FCM console you cannot send data only messages. |
Edit: const unsubscribe = messaging().onMessage(async remoteMessage => {
// When app in foreground
console.log('Message handled in the foregroud!', remoteMessage);
showNotification(remoteMessage);
});
return () => {
return unsubscribe;
}; to this; const unsubscribe = messaging().onMessage(async remoteMessage => {
// When app in foreground
console.log('Message handled in the foregroud!', remoteMessage);
showNotification(remoteMessage);
});
return unsubscribe; And twice notification problem resolved. |
Yes I realized that when I try to send data message in Firebase Console. I am using REST in Django with this package. |
Have to mention: The callback problem is only on iOS for me. On Android everything works as expected. I'm using the latest You could try to update the version of |
It is weird. I updated both app and messaging packages to 6.7.0 but still getting null in getInitialNotification on Android. Not tried in iOS because I want to resolve this first. Edit 1: [email protected] not worked as well. Return null in getInitialNotification when I press the notification. Do I missing something? |
This notification issue completely takes me away from React Native. There should not be so much gap on such an important issue. There is no proper documentation. |
did you solve your problem ? |
Welcome to OSS. We've setup a test app on our org, just need assign one of the team some time to install various modules to cross test integration. It's looking like it'll be next week though. |
I could not solve the problem. Looks like I will not able to. I removed firebase totally from the project and tried OneSignal. It is really impressive. All the problems solved in easier way. You should give it a try. |
I am facing exactly same issue, I have tried all possible combination of data only, data+notification and notification only. |
I got |
Hello 👋, to help manage issues we automatically close stale issues.
|
Issue is still require the community's attention for future visitors and users. |
Please don't use react native splash screen if you are facing issue in notification or add
in SplashActivity.java |
What worked for me and fixed the multiple notifications problem was remove the other previous services (from react-native-firebase v5 configuration) from manifest and add this one:
in AndroidManifest.xml |
if i
if i use this then messaging().onNotificationOpenedApp() and messaging() |
Hello 👋, to help manage issues we automatically close stale issues.
|
In my case, this was due to hot-reloading.
So every time I do a hot reload it gets re-registered and show multiple notifications. Just restart the app and it will work fine. Make sure to Unsubscribe on unmount. |
Issue
Hi! I am Enes. I am developing a mobile application with react-native-firebase. I migrate my application v5 to v6 with documentation in rnfirebase.io migration to v6. Everything is fine. I got notifications in foreground, background and quit states. But the issue for me is that;
getInitialNotification
not returning the notification message, it returns nullgetInitialNotification
So I decided to use https://rnfirebase.io/migrating-to-v6 with rn-firebase v6 as you suggested here
I used PushNotification.localNotification() method. That resolved the issue little bit. But another issue happened. This time it shows me two notification in status bar. But displays the notification by the way from top.
Some code snippets from my app;
In App.js file, I use setBackgroundMessageHandler as you suggested in documentation.
and
in main
index.js
fileMost of the code snippets are guided from documentation. Not specific code here.
I totally messed up. Any reference and guide for this setup (react-native-firebase + react-native-push-notification) or any other suggestion would be great.
Thanks in advance.
Project Files
Javascript
Click To Expand
package.json
:# N/A
firebase.json
for react-native-firebase v6:iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
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:e.g. 6.4.0
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?N
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: