title: Flutter Firebase Cloud Messaging onMessage is triggered twice
body: <p>I already implemented the basic configuration suggested by the firebase_messaging flutter package. However, each time that I receive a notification on my flutter app onMessage is triggered twice. I'm using firebase_messaging 6.0.9, Dart 2.7.0 and Flutter 1.12.13+hotfix.5.</p>
  <p>This is my [project]/android/build.gradle</p>
  <pre><code>    buildscript {
      repositories {
          google()
          jcenter()
      }
  
      dependencies {
          classpath 'com.android.tools.build:gradle:3.5.0'
          classpath 'com.google.gms:google-services:4.3.2'
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
      }
  }
  
  rootProject.buildDir = '../build'
     subprojects {
         project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
     }
     subprojects {
         project.evaluationDependsOn(':app')
     }
  
     task clean(type: Delete) {
         delete rootProject.buildDir
     }
  </code></pre>
  <p>This is my [project]/android/app/build.gradle</p>
  <pre><code>def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  if (localPropertiesFile.exists()) {
      localPropertiesFile.withReader('UTF-8') { reader -&gt;
          localProperties.load(reader)
      }
  }
  
  def flutterRoot = localProperties.getProperty('flutter.sdk')
  if (flutterRoot == null) {
      throw new GradleException(&quot;Flutter SDK not found. Define location with flutter.sdk in the local.properties file.&quot;)
  }
  
  def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
  if (flutterVersionCode == null) {
      flutterVersionCode = '1'
  }
  
  def flutterVersionName = localProperties.getProperty('flutter.versionName')
  if (flutterVersionName == null) {
      flutterVersionName = '1.0'
  }
  
  apply plugin: 'com.android.application'
  apply from: &quot;$flutterRoot/packages/flutter_tools/gradle/flutter.gradle&quot;
  
  android {
      compileSdkVersion 28
  
      lintOptions {
          disable 'InvalidPackage'
      }
  
      defaultConfig {
          // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
          applicationId &quot;com.example.chat_notification&quot;
          minSdkVersion 16
          targetSdkVersion 28
          versionCode flutterVersionCode.toInteger()
          versionName flutterVersionName
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
      }
  
      buildTypes {
          release {
              // TODO: Add your own signing config for the release build.
              // Signing with the debug keys for now, so `flutter run --release` works.
              signingConfig signingConfigs.debug
          }
      }
  }
  
  flutter {
      source '../..'
  }
  
  dependencies {
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'androidx.test:runner:1.1.1'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
  }
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  <p>And this is the code where the onMessage is triggered twice</p>
  <pre><code>import 'package:chat_notification/model/message.dart';
  import 'package:firebase_messaging/firebase_messaging.dart';
  import 'package:flutter/material.dart';
  
  class MessageWidget extends StatefulWidget {
    @override
    _MessageWidgetState createState() =&gt; _MessageWidgetState();
  }
  
  class _MessageWidgetState extends State&lt;MessageWidget&gt; {
  
    FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
    List&lt;Message&gt; messages = [];
  
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      _firebaseMessaging.configure(
        onMessage: (Map&lt;String, dynamic&gt; response) async {
          print(&quot;onMessage: $response&quot;);
        },
        onLaunch: (Map&lt;String, dynamic&gt; response) async {
          print(&quot;onLaunch: $response&quot;);
        },
        onResume: (Map&lt;String, dynamic&gt; response) async {
          print(&quot;onResume: $response&quot;);
        },
      );
    }
  
    @override
    Widget build(BuildContext context) =&gt; ListView(
      children: messages.map(buildMessage).toList(),
    );
  
    Widget buildMessage(Message message) =&gt; ListTile(
      title: Text(message.title),
      subtitle: Text(message.body),
    );
  }
  </code></pre>
  <p>I already try creating new projects but it seems to happen for each of them. I would really appreciate if anyone can help me about this.</p>
  <p><strong>EDIT:</strong></p>
  <p>This is no longer present in latest version of firebase_messaging: 7.0.0. Best solution I found is updating the package. Duplicated messages are not longer present.</p>