-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[firebase_messaging]: onMessage listener fires twice on iOS18 devices #13366
Comments
I'm having the same problem. [Environment] |
Hello, Is it working fine in the android application? Can you tell me? |
On Android it is working as expected. @soumyajitdas365 |
@soumyajitdas365 |
Can you help by providing the code for Android? |
I have faced the same issue today after upgrading to iOS 18. |
Please refer to the official documentation https://firebase.google.com/docs/flutter/setup?platform=android |
Thanks for the insight. I will test that myself. |
Yes indeed in my function log i also see that the notification is sent once and i have tried to sent it from my local machine using the firebase admin sdk, it doesn't send 2 notifications server-side. Besides, the client listener is only fired once on my android device using and on my iOS 17.5.1 device it fires only once the client listener 🙏🏻 |
Same problem here. I upgraded to Xcode 16.0 and iOS18 and now the onMessage listener fires twice every time a message is received. |
Same problem, I would like to know which version is available for the current situation? |
Same problem here, I wish I found this earlier because I was struggling for 13 hours thinking the problem in my code. |
Since this is only happening when the app is in foreground, it would be better to save the message ids to an array at runtime. This way you can check whether the corresponding message id is already existing in the array and thus already been processed. Then you can just ignore any further messages with the same id. |
Hi @justChris , thanks for submitting this issue. I'm going to upgrade my iOS to version 18 since it's prerequisite to reproduce this issue. I'd provide feedback on my findings. |
Also facing the same issue. Did some tests from my side. Flutter version: Firebase dependencies: firebase_core: 3.3.0 Devices Tested: iOS 18.0 (iPhone 15 Pro): Messaging received twice when app is in the foreground. |
Hi @justChris , I'm able to reproduce this issue on iOS 18. |
Hi guys, we have the same issue. We are receiving on iOS 18 devices events onMessage twice. On iOS 17 device with the same code base it is only fired once. Very critical bug. |
Yes, I think it's the best way to deal with the bug until we get a fixed version of Firebase lib. final _recievedMessages = <String>[];
void _onMessageHandler(RemoteMessage message) {
final messageId = message.messageId;
if (_recievedMessages.contains(messageId)) {
return;
}
if (messageId != null) {
_recievedMessages.add(messageId);
}
// your message handle logic here
}
StreamSubscription? _onMessageSubscription;
_onMessageSubscription ??= FirebaseMessaging.onMessage.listen(_onMessageHandler); |
For me onMessage.listen is not invoked, it's a really big issue on IOS18 |
Hello all, we are investigating this issue, but it seems to be a bug in iOS 18 not directly related to FlutterFire: https://forums.developer.apple.com/forums/thread/761597 |
Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
Since I upgraded to xcode16.0 and iOS18 the onMessage listener fires twice every time a message is received. This only happens with the onMessage listener, means when the app is in foreground. When the app is in background or terminated, this does NOT happen. And also this only happens on physical devices with iOS18. On devices with iOS17, the listener fires once per message, as expected.
I ensured that the listener is not subscribed multiple times, but still it fires twice.
Reproducing the issue
Firebase Core version
3.5.0
Flutter Version
3.24.3
Relevant Log Output
Flutter dependencies
Expand
Flutter dependencies
snippetAdditional context and comments
No response
The text was updated successfully, but these errors were encountered: