firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.61k stars 3.95k forks source link

firebase_messaging package error - FirebaseMessaging.onMessage.listen triggers message multiple times #6939

Closed Muhammed-anas-pk closed 2 years ago

Muhammed-anas-pk commented 3 years ago

Here is my code sample

FirebaseMessaging.onMessage.listen((message) async {
 onMessage: (message) async {

 showDialog(
context: context,
builder: (context) => AlertDialog(
   contentPadding:
        const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
  content: Container(
      child: Column(
         mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
      children: [
          message.notification != null
             ? Text('${message.notification.title}')
              : Container(
               height: 0,
                ),
        message.notification.body != null
              ? Text('${message.notification.body}')
             : Container(
         height: 0,
              ),
         ],
      ),
   ),

 ),
)

Iam using latest upgraded firebase_messaging package (version 10.0.6)..it works properly when i downgraded to version 7.0.3

markusaksli-nc commented 3 years ago

Hi @Muhammed-anas-pk Could you please provide your flutter doctor -v and flutter pub deps -- --style=compact? A minimal complete reproducible code sample we could just paste into main.dart would be very helpful here. Thank you

Muhammed-anas-pk commented 3 years ago

flutter doctor -v results..

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-US) • Flutter version 2.2.3 at /Users/user/Downloads/flutter • Framework revision f4abaa0735 (9 weeks ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /usr/local/share/android-sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /usr/local/share/android-sdk • ANDROID_SDK_ROOT = /usr/local/share/android-sdk • Java binary at: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1, Build version 12E507 • CocoaPods version 1.11.0.beta.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.59.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • iPhone 11 (mobile) • 030BAC31-FB62-41C8-A81B-8F10A090B1CC • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator) • Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159

! Doctor found issues in 1 category.

and flutter pub deps -- --style=compact results

Dart SDK 2.13.4 Flutter SDK 2.2.3 qdely 1.0.3+8

dependencies:

dev dependencies:

transitive dependencies:

markusaksli-nc commented 3 years ago

Can you provide a minimal complete reproducible code sample?

google-oss-bot commented 2 years ago

Hey @Muhammed-anas-pk. 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!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@Muhammed-anas-pk if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.