Try with data as placed at last, we have faced the same issue
On Jul 13, 2016 7:06 PM, "Alain Bonnefoy" <[email protected]> wrote:

> Hello,
>
> Data messages *are succesfully sent* via Advanced REST client, but not
> received anymore when my application is in background (no problem in
> foreground).
>
> But I really don't understand why....
>
> My manifest is:
>
> <?xml version="1.0" encoding="utf-8"?>
> <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">
>
>     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
>     <uses-permission android:name="android.permission.INTERNET" />
>     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
>     <uses-permission android:name="com.my.MY_SERVICE_PERMISSION" />
>     <uses-permission android:name="android.permission.CAMERA" />
>     <uses-permission android:name="android.permission.WRITE_CALENDAR" />
>     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" 
> />
>     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
>     <uses-permission android:name="android.permission.VIBRATE" />
>     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" 
> />
>     <uses-permission android:name="android.permission.BLUETOOTH" />
>     <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
>     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" 
> />
>
>     <uses-feature android:name="android.hardware.camera" />
>
>     <application
>         android:allowBackup="true"
>         android:icon="@mipmap/ic_launcher"
>         android:label="@string/app_name"
>         android:logo="@mipmap/ic_launcher">
>
>         <activity
>             android:name=".MainActivity"
>             android:configChanges="keyboardHidden|orientation|screenSize"
>             android:label="@string/app_name">
>
>             <intent-filter>
>                 <action android:name="android.intent.action.MAIN" />
>
>                 <category android:name="android.intent.category.LAUNCHER" />
>             </intent-filter>
>
>         </activity>
>
>         <service android:name=".MyFcmListenerService">
>             <intent-filter>
>                 <action android:name="com.google.firebase.MESSAGING_EVENT" />
>             </intent-filter>
>         </service>
>
>         <service
>             android:name=".MyInstanceIDListenerService">
>             <intent-filter>
>                 <action android:name="com.google.firebase.INSTANCE_ID_EVENT" 
> />
>             </intent-filter>
>         </service>
>
>         <service
>             android:name=".RegistrationIntentService"
>             android:exported="false" />
>
>     </application>
>
> </manifest>
>
>
> My gradle:
>
> apply plugin: 'com.android.application'
>
> android {
>     compileSdkVersion 24
>     buildToolsVersion '23.0.3'
>
>     defaultConfig {
>         applicationId "com.my.example"
>         minSdkVersion 19
>         targetSdkVersion 23
>     }
>
>     buildTypes {
>         release {
>             minifyEnabled false
>             proguardFiles getDefaultProguardFile('proguard-android.txt'), 
> 'proguard-rules.txt'
>         }
>     }
>     compileOptions {
>         sourceCompatibility JavaVersion.VERSION_1_7
>         targetCompatibility JavaVersion.VERSION_1_7
>     }
>
>     packagingOptions {
>         exclude 'META-INF/DEPENDENCIES'
>         exclude 'META-INF/NOTICE'
>         exclude 'META-INF/LICENSE'
>         exclude 'META-INF/LICENSE.txt'
>         exclude 'META-INF/NOTICE.txt'
>     }
> }
>
> repositories {
>     mavenCentral()
>     flatDir {
>         dirs 'libs'
>     }
>     maven { url "https://jitpack.io"; }
> }
>
> 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.code.gson:gson:2.4'
>     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'
>
>
> And My listener:
>
> public class MyFcmListenerService extends FirebaseMessagingService {
>     public static final int NOTIFICATION_ID = 1;
>
>     private static final String TAG = "MyFcmListenerService";
>
>     /**
>      * Called when message is received.
>      *
>      * @param fcmMessage FCM message containing message data as key/value 
> pairs.
>      *             For Set of keys use data.keySet().
>      */
>     // [START receive_message]
>     @Override
>     public void onMessageReceived(RemoteMessage fcmMessage) {
>
>         Map data = fcmMessage.getData();
>
>         Spanned span = null;
>         String id;
>         String title;
>         String message;
>         String webSite;
>         String image;
>         String location;
>         String latitude;
>         String longitude;
>         String startDate;
>         String endDate;
>         String publishEndDate;
>         SharedPreferences sharedPreferences = 
> PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
>         SharedPreferences.Editor editor = sharedPreferences.edit();
>
>         int code = Integer.parseInt((String) data.get("code"));
>
>         Log.i(Constants.APP_TAG, "received FCM message code "  + code);
>
>         switch (code) {
>             case 1: // Event
>                 . . . .
>                 break;
>
>             default:
>                 break;
>         }
>     // [END_EXCLUDE]
>     }
>     // [END receive_message]
>
>
> And Strangely, when I receive a message in foreground and generate a
> custom notification with the data, if I swipe the application out of the
> recent app list, the notification is automatically removed from the
> notification center.
> It ws not the case when this same application was able to receive data
> message in background.
> I guess there is some relationship.
>
> The sent message is:
>
> {
>   "to" : "dlThm37OT8w:APA91bFRIcL4o5R2eX1jH0Fd-hAaPu9Wu_. . .
> ._MSBzgajJotZ-CR4VTKBRE",
>   "data": {
>     "id": 19,
>     "title": "Title test",
>     "msg": "Text of the test",
>     "code": 2,
>     "infosUrl": "www.myexample.com",
>     "eventLocation": "Nowhere",
>     "latitude": 44.90022515672,
>     "longitude": 5.0196307059377,
>     "startDate": "2016/05/14 20:00",
>     "endDate": "2016/05/14 22:00",
>     "publishEndDate": "",
>     "image": ""
>   },
>   "delay_while_idle" : false,
>   "priority" : "high",
>   "content_available" : true
> }
>
> Do you see anything which could explain my problem?
>
> Regards,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/19c5c0d7-4d8c-479a-a8b1-54cdb3d978ba%40googlegroups.com
> <https://groups.google.com/d/msgid/android-developers/19c5c0d7-4d8c-479a-a8b1-54cdb3d978ba%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAJ9LBw7NtkRSRv7HUL3WZ_H_-Ltr_qkq2%2B0XthMhjpW-xsu-Fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to