title: Getting Same Firebase Notification multiple times
body: <p>I am using firebase to get notifications of subscribed topics. FirebaseMessagingService receives same notification multiple times. I have tried all of the provided solutions but nothing worked for me. Any help would be highly appreciated. Thanks in Advance.</p>
  
  <p><strong>Module Gradle</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 25
      buildToolsVersion "24.0.3"
  
      defaultConfig {
          applicationId "abc.abc"
          minSdkVersion 19
          targetSdkVersion 25
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:25.3.1'
      compile 'com.squareup.retrofit:retrofit:1.9.0'
      compile 'com.squareup.okhttp:okhttp:2.4.0'
      compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
      compile 'com.github.bumptech.glide:glide:3.5.2'
      compile 'com.wang.avi:library:2.1.3'
      compile 'com.google.firebase:firebase-messaging:11.0.4'
      compile 'com.facebook.fresco:fresco:1.5.0'
  
  }
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p><strong>Project Gradle</strong></p>
  
  <pre><code>sub-projects/modules.
  
  buildscript {
      repositories {
  
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.0'
          classpath 'com.google.gms:google-services:3.1.0'
  
      }
  }
  
  allprojects {
      repositories {
          jcenter()
  
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>  &lt;service android:name=".Firebase.MyFirebaseMessagingService" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
          &lt;service android:name=".Firebase.MyFirebaseInstanceIDService"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  </code></pre>
  
  <p><strong>FirebaseMessagingService</strong>
  This override function getting called multiple times despite of the fact that i am sending single notification.</p>
  
  <pre><code>public class MyFirebaseMessagingService extends FirebaseMessagingService {
  
      private static final String TAG = "MyFirebaseMsgService";
  
      @Override
      public void onMessageReceived(RemoteMessage remoteMessage) {
          //Displaying data in log
          //It is optional
          String refreshedToken = FirebaseInstanceId.getInstance().getToken();
          Log.d(TAG,refreshedToken);
          Log.d(TAG, "From: " + remoteMessage.getFrom());
          Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
  
          //Calling method to generate notification
          sendNotification(remoteMessage.getNotification().getBody());
      }
  
   private void sendNotification(String messageBody) {
          Intent intent = new Intent(this, MainActivity.class);
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
                  PendingIntent.FLAG_ONE_SHOT);
  
          Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
          NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                  .setSmallIcon(R.drawable.bazaar_noti_small)
                  .setContentTitle("Price Updated")
                  .setContentText(messageBody)
                  .setAutoCancel(true)
                  .setSound(defaultSoundUri)
                  .setContentIntent(pendingIntent);
  
          NotificationManager notificationManager =
                  (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  
          notificationManager.notify(0, notificationBuilder.build());
      }
  }
  </code></pre>