Skip to content

🐛 [firebase_messaging] v8.0.0-dev.2 onMessage is fired twice #3991

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

Closed
LasseRosenow opened this issue Oct 29, 2020 · 12 comments
Closed

🐛 [firebase_messaging] v8.0.0-dev.2 onMessage is fired twice #3991

LasseRosenow opened this issue Oct 29, 2020 · 12 comments
Assignees
Labels
Needs Attention This issue needs maintainer attention. plugin: messaging type: bug Something isn't working

Comments

@LasseRosenow
Copy link

LasseRosenow commented Oct 29, 2020

Bug report

Since I updated to firebase_messaging v8.0.0-dev.1 or dev.2 its the same.. onMessage is fired twice, when I get a message.

D/FLTFireMsgReceiver(22164): broadcast received for message
I/flutter (22164): {data: {moduleId: 113a20f6-08ce-47a5-a85c-b0179b6b862a, type: updateData, title: Test, message: Test Nachricht}, messageId: 0:1603998491174878%06db50d7f9fd7ecd, sentTime: 1603998490818, from: /topics/schulinfoapp_beta-v4_283, ttl: 86400}
I/flutter (22164): onMessage: Instance of 'RemoteMessage'
I/flutter (22164): onMessage: Instance of 'RemoteMessage'

Steps to reproduce

Use the firebase_messaging example with v8.0.0 and receive a message.

Expected behavior

onMessage should only be called once.

@LasseRosenow LasseRosenow added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 29, 2020
@darshankawar
Copy link

@lazylazyllama
There's similar open issue describing your case, 1669.
Please follow-up there for updates and any questions you may have.
Closing this as duplicate.

@LasseRosenow
Copy link
Author

True, but this issue is very old and is about the old firebase_messaging version. Which is weird, because the old version worked perfectly fine for me. I only experienced this issue specifically in the 8.0.0+ versions.

@Salakar
Copy link
Member

Salakar commented Nov 3, 2020

@lazylazyllama which platform are you seeing this behavior on?

@LasseRosenow
Copy link
Author

Android

@Salakar
Copy link
Member

Salakar commented Nov 3, 2020

Ok thanks, I'll try see if we can reproduce this.

@darshankawar darshankawar removed the Needs Attention This issue needs maintainer attention. label Nov 4, 2020
@Salakar
Copy link
Member

Salakar commented Nov 5, 2020

Please can you try 8.0.0-dev.6 - this should now be fixed.

@Salakar Salakar closed this as completed Nov 5, 2020
@LasseRosenow
Copy link
Author

I just tried it, but sadly the issue is still there

@Salakar
Copy link
Member

Salakar commented Nov 5, 2020

Could you share your dart code? Thanks

@Salakar Salakar reopened this Nov 5, 2020
@Salakar Salakar added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Nov 5, 2020
@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Nov 16, 2020
@google-oss-bot
Copy link

Hey @lazylazyllama. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@LasseRosenow
Copy link
Author

I'll try to build a reproducible example within the next week. Sadly I'm very busy right now, and the codebase in which I encountered this problem is way to complicated to just upload it here .. considering business logic etc.

Also while playing around a bit last week I was able to reproduce that this issue does not occur after I stripped down my application down to the very basics, so it's quite a complicated thing to figure out what actually is causing the problem.

But I'll figure it out. I just can't say when I will find time. If this issue gets closed I'll just open a new one, as soon as I have a reproducible example :)

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed Stale Issue with no recent activity blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Nov 16, 2020
@pureimpro
Copy link

@lazylazyllama I was facing this issue also, and realized via VSCode widget Inspector, that two instances of the same widgets were present in the widget tree (i.e. my home page), and each one of them was triggered by firebase messages. Maybe you're in a similar situation with your app. I had misconfigured my splash screen page to push my home page on top of my root page (which actually is my home page) and that was my mistake. Hope that helps

@LasseRosenow
Copy link
Author

@pureimpro actually this is exactly what was going on at my side aswell :O thank you very very much :) You saved quite a lot of time :)

I was using a custom static method called initializeFcmNotification(), in which I set up FirebaseMessaging.onMessage.listen((message) {}. Because my ui rerendered once, this function was called twice and thus the onMessage body would be called twice aswell on every incoming message.

I fixed it by adding a flag to check, if initializeFcmNotification() is called for the first time or not.

@firebase firebase locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. plugin: messaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants