title: FCM - Getting push notification data twice
body: <p>I've been struggling with this issue for a long time so I decided to ask you.</p>
  
  <p>I'm developing a chat app and for push notifications I'm using Firebase Functions. I'm getting always the data from onMessageReceived twice. For some people the solution was removing de gcm dependencies and use only the firebase ones but i think is not my case. Anyway I'm showing you all the code:</p>
  
  <p>This is my index.js:</p>
  
  <pre><code>exports.notifications = functions.database.ref('chats/{chatUid}/messages/{pushId}').onWrite( (change, context) =&gt; {
  
  var valueObject = change.after.val();
  var chatUid = change.after.ref.parent.parent.key;
  
  var data = {
      'data' : {
          'conversation_id' : chatUid,
          'message_key' : change.after.key,
          'message_title' : valueObject.title,
          'message_body' : valueObject.message,
          'userFrom' : valueObject.userFrom.toString()
      }
  };
  
  const options = {
      priority: "high",
      timeToLive: 60 * 60 * 24
  };
  
  return admin.messaging().sendToTopic(chatUid, data, options)
  
  
  });
  </code></pre>
  
  <p>My gradle settings:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'
  apply plugin: 'com.google.gms.google-services'
  
  android {
      compileSdkVersion 27
      defaultConfig {
      applicationId "xxx"
      minSdkVersion 21
      targetSdkVersion 27
      versionCode xxx
      versionName "x.x.x"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  }
  buildToolsVersion '27.0.3'
  productFlavors {
  }
  }
  
  ext {
      support_version = '27.1.1'
  }
  
  dependencies {
  
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  
  implementation "com.android.support:design:$support_version"
  
  implementation "com.android.support:appcompat-v7:$support_version"
  implementation "com.android.support:customtabs:$support_version"
  implementation "com.android.support:support-v4:$support_version"
  implementation "com.android.support:cardview-v7:$support_version"
  implementation 'com.android.support.constraint:constraint-layout:1.1.2'
  implementation "com.android.support:percent:$support_version"
  implementation "com.android.support:recyclerview-v7:$support_version"
  
  implementation 'com.android.support:support-v4:27.1.1'
  testImplementation 'junit:junit:4.12'
  
  implementation 'com.squareup.retrofit2:retrofit:2.3.0'
  implementation 'com.google.code.gson:gson:2.8.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
  implementation('com.squareup.retrofit2:retrofit:2.3.0') {
      exclude module: 'okhttp'
  }
  implementation 'com.google.code.gson:gson:2.8.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
  implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
  implementation 'com.squareup.okhttp3:okhttp:3.9.0'
  implementation 'com.squareup.retrofit2:converter-jackson:2.1.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
  implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
  implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
  
  implementation 'com.squareup.picasso:picasso:2.5.2'
  implementation 'de.hdodenhof:circleimageview:2.2.0'
  
  implementation 'com.google.android.gms:play-services-auth:15.0.1'
  implementation 'com.google.android.gms:play-services-maps:15.0.1'
  implementation 'com.google.android.gms:play-services-location:15.0.1'
  implementation 'com.google.maps.android:android-maps-utils:0.5'
  
  implementation 'com.facebook.android:facebook-android-sdk:4.18.0'
  
  implementation 'com.google.firebase:firebase-analytics:16.0.1'
  implementation 'com.google.firebase:firebase-database:16.0.1'
  implementation 'com.google.firebase:firebase-storage:16.0.1'
  implementation 'com.google.firebase:firebase-auth:16.0.2'
  implementation 'com.google.firebase:firebase-config:16.0.0'
  implementation 'com.google.firebase:firebase-core:16.0.1'
  implementation 'com.google.firebase:firebase-messaging:17.1.0'
  
  implementation 'com.firebaseui:firebase-ui-database:3.3.1'
  implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
  implementation 'commons-codec:commons-codec:1.11'
  
  androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'}
  </code></pre>
  
  <p>Thank you for your time :D</p>