Is FCM messaging working well for unpublished app?
<p>that's not the first time I'm wondering how GCM/FCM works when the application is in background.</p>

<p>And now I'm modifying my application I realize that it doesn't receive <code>data</code> messages when the application is in background whereas the same message is well received by application in foreground.</p>

<p>if I install the published one from Google Play, it's working well in all cases.  </p>

<p>If I get the published app's project back and rebuild it, FCM messages are not received when the app is in background. That's a nightmare.</p>

<p>So I'm wondering if FCM is fully working for unpublished application !?!</p>

<p>My message is (tested from Advanced Rest Client):</p>

<pre><code>{
  "registration_ids": [
    "feWpp3aQ8sQ:A...dclQ1hSttsf",
    "feDmzDRi-gw:A...O9ur7oXi",
    "f7dbqek_rPo:APA91bEu...a1rSje0bNmPq8"
  ],
  "data": {
    "id": 19,
    "title": "Title test",
    "msg": "Text of the test",
    "code": 2,
    "infosUrl": "www.myexample.com",
    "eventLocation": "Nowhere",
    "latitude": 47.90022515672,
    "longitude": 15.0196307059377,
    "startDate": "2016/05/14 20:00",
    "endDate": "2016/05/14 22:00",
    "publishEndDate": "",
    "image": ""
  },
  "delay_while_idle": false,
  "priority": "high",
  "content_available": true
}
</code></pre>

<p>My Manifest:</p>

<pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.my.example"
  android:installLocation="auto"
  android:versionCode="52"
  android:versionName="@string/app_version"&gt;

  &lt;application
      android:allowBackup="true"
      android:hardwareAccelerated="false"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:logo="@mipmap/ic_launcher"&gt;

      &lt;activity
          android:name=".MainActivity"
          android:configChanges="keyboardHidden|orientation|screenSize"
          android:label="@string/app_name"&gt;

          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;

              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;

          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.SEARCH" /&gt;
          &lt;/intent-filter&gt;

      &lt;/activity&gt;

      &lt;activity
          android:name=".PreferencesActivity"
          android:label="@string/label_preferenceScreen"/&gt;

      &lt;activity
          android:name=".FragmentPreferences"
          android:label="@string/label_preferenceScreen"/&gt;

      &lt;service android:name=".MyFcmListenerService"&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=".MyInstanceIDListenerService"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;

      &lt;service
          android:name=".RegistrationIntentService"
          android:exported="false" /&gt;

  &lt;/application&gt;
</code></pre>

<p></p>

<p>My gradle:</p>

<pre><code>dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile 'com.android.support:support-v4:24.0.0'
  compile 'com.android.support:support-annotations:24.0.0'
  compile 'org.osmdroid:osmdroid-android:5.2@aar'
  compile 'com.google.firebase:firebase-messaging:9.2.0'
  compile 'com.google.android.gms:play-services-location:9.2.0'
  compile 'com.google.android.gms:play-services-appindexing:9.2.0'
  compile 'com.android.support:appcompat-v7:24.0.0'
}
apply plugin: 'com.google.gms.google-services'
</code></pre>

<p>And the Listener:</p>

<pre><code>public class MyFcmListenerService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage fcmMessage) {

        Map data = fcmMessage.getData();

        int code = Integer.parseInt((String) data.get("code"));

        switch (code) {
          case 1: // Event
              ....
              break;


          default:
              break;
        }
    }
}
</code></pre>

<p>Did you experience such strange problem??</p>