-
Notifications
You must be signed in to change notification settings - Fork 2.3k
-
I found this issue where there was the following response:
The two notifications arrive as the OS of your phone handles any Push notification which includes the notification tag.
So, for a message containing
{
"notification": {
"title":"Test",
"body":"Test",
}
}
The OS will present the user with this notification. Then either onMessage or setBackgroundMessageHandler will be triggered, depending on the application state. In both you present the user a local notification. So, it’s just natural the you currently have two notifications.
I don't currently have onMessage or setBackgroundMessageHandler and I am still seeing this issue. Any thoughts? I was previously using react-native-notifications and have uninstalled that and as far as I can tell removed any trace of it except for maybe implementation "com.google.android.gms:play-services-gcm:16.0.0".
Beta Was this translation helpful? Give feedback.
All reactions
Any other thoughts?
Replies: 3 comments 7 replies
-
maybe try npx react-native-clean-project to make extra sure
It certainly sounds like either two payloads are coming in, or you have two handlers (either in the SDKs default behavior, or in packages you've integrated).
Beta Was this translation helpful? Give feedback.
All reactions
-
I gave that a try and haven't noticed any difference, unfortunately.
Beta Was this translation helpful? Give feedback.
All reactions
-
Any other thoughts?
Beta Was this translation helpful? Give feedback.
All reactions
-
Sounds good. I will see if I can reproduce it in a smaller setting not bound to the existing project. Is there anything you can think of that we can look for that might cause this? Maybe unnecessary Gradle dependencies or something? I'll keep digging.
Beta Was this translation helpful? Give feedback.
All reactions
-
multiple registration of listeners somehow is what I'd look for, either in javascript listeners or perhaps two native listeners from two firebase libraries somehow
Beta Was this translation helpful? Give feedback.
All reactions
-
So, we previously used GCM and as far as I can tell the only remnant of that is implementation "com.google.android.gms:play-services-gcm:16.0.0" in our app/build.gradle. If I remove that, I don't get any notifications and instead get the following error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzq;
at com.google.android.gms.gcm.GcmReceiver.onReceive(Unknown Source:86)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3788)
at android.app.ActivityThread.access1400ドル(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Is there a step I am missing from the installation of RNFB? I found this from the Google docs: https://developers.google.com/cloud-messaging/android/android-migrate-fcm but that should be included in RNFB, no?
Beta Was this translation helpful? Give feedback.
All reactions
-
Actually, I think I figured it out. We also had react-native-intercom which had its own receiver outside of our code (which is why I couldn't find anything). They have instructions for using FCM and following that seems to have fixed the issue.
Beta Was this translation helpful? Give feedback.
All reactions
-
intercom can apparently play poorly with iOS on iOS14 causing crashes on cloud message receipt. Not sure what they are doing under the covers, but I'm sure they are listening for cloud messages so I'm not surprised they were the second receiver. Glad you found it!
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello guys, I think I have a solution for this.
messaging.onBackgroundMessage((payload) => {}) to messaging.setBackgroundMessageHandler(async (payload) => {})
// This will override Firebase's default behavior
Beta Was this translation helpful? Give feedback.