{"action":"created","issue":{"url":"https://api.github.com/repos/firebase/quickstart-android/issues/89","repository_url":"https://api.github.com/repos/firebase/quickstart-android","labels_url":"https://api.github.com/repos/firebase/quickstart-android/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/firebase/quickstart-android/issues/89/comments","events_url":"https://api.github.com/repos/firebase/quickstart-android/issues/89/events","html_url":"https://github.com/firebase/quickstart-android/issues/89","id":166092710,"number":89,"title":"quickstart-android messaging app doesn't receive data messages in background","user":{"login":"2ndGAB","id":14370028,"avatar_url":"https://avatars.githubusercontent.com/u/14370028?v=3","gravatar_id":"","url":"https://api.github.com/users/2ndGAB","html_url":"https://github.com/2ndGAB","followers_url":"https://api.github.com/users/2ndGAB/followers","following_url":"https://api.github.com/users/2ndGAB/following{/other_user}","gists_url":"https://api.github.com/users/2ndGAB/gists{/gist_id}","starred_url":"https://api.github.com/users/2ndGAB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2ndGAB/subscriptions","organizations_url":"https://api.github.com/users/2ndGAB/orgs","repos_url":"https://api.github.com/users/2ndGAB/repos","events_url":"https://api.github.com/users/2ndGAB/events{/privacy}","received_events_url":"https://api.github.com/users/2ndGAB/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"kroikie","id":2370200,"avatar_url":"https://avatars.githubusercontent.com/u/2370200?v=3","gravatar_id":"","url":"https://api.github.com/users/kroikie","html_url":"https://github.com/kroikie","followers_url":"https://api.github.com/users/kroikie/followers","following_url":"https://api.github.com/users/kroikie/following{/other_user}","gists_url":"https://api.github.com/users/kroikie/gists{/gist_id}","starred_url":"https://api.github.com/users/kroikie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kroikie/subscriptions","organizations_url":"https://api.github.com/users/kroikie/orgs","repos_url":"https://api.github.com/users/kroikie/repos","events_url":"https://api.github.com/users/kroikie/events{/privacy}","received_events_url":"https://api.github.com/users/kroikie/received_events","type":"User","site_admin":false},"assignees":[{"login":"kroikie","id":2370200,"avatar_url":"https://avatars.githubusercontent.com/u/2370200?v=3","gravatar_id":"","url":"https://api.github.com/users/kroikie","html_url":"https://github.com/kroikie","followers_url":"https://api.github.com/users/kroikie/followers","following_url":"https://api.github.com/users/kroikie/following{/other_user}","gists_url":"https://api.github.com/users/kroikie/gists{/gist_id}","starred_url":"https://api.github.com/users/kroikie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kroikie/subscriptions","organizations_url":"https://api.github.com/users/kroikie/orgs","repos_url":"https://api.github.com/users/kroikie/repos","events_url":"https://api.github.com/users/kroikie/events{/privacy}","received_events_url":"https://api.github.com/users/kroikie/received_events","type":"User","site_admin":false}],"milestone":null,"comments":37,"created_at":"2016-07-18T13:25:10Z","updated_at":"2016-08-08T19:59:12Z","closed_at":"2016-08-08T19:59:12Z","body":"### Step 1: Are you in the right place?\r\n\r\n  * Issues related to the code **in this repository**.\r\n\r\n### Step 2: Describe your environment\r\n\r\n  * Android device: Asus Nexus 7 wifi\r\n  * Android OS version: 6.0.1\r\n  * Google Play Services version: 3.0.0\r\n  * Firebase/Play Services SDK version: 9.2.1\r\n  \r\nBut I cannot get it working on Nexus 7 LTE 6.0.1 or Samsung GT-9295 5.0.1 as well.\r\n\r\n### Step 3: Describe the problem:\r\n\r\nI send the following message with Advanced REST Client, the message is sent successfully, but is only received in foreground and not when the application is in background.\r\n\r\n    {\r\n        \"to\" : \"egu9jGiMcew:APA91bFv2RewdzlrC4Q0 ... dYZgv91oZVfTtrfAojLMKZZmEURvbq-aA2\",\r\n        \"data\": {\r\n            \"title\": \"Title test\",\r\n            \"msg\": \"Text of the test\",\r\n            \"code\": 2\r\n        },\r\n        \"delay_while_idle\" : false,\r\n        \"priority\" : \"high\",\r\n        \"content_available\" : true\r\n    }\r\n\r\n#### Steps to reproduce:\r\n\r\n  1. Build the quickstart-android project\r\n  2. Execute the messaging app\r\n  3. Send it a data message when the application is in background\r\n  \r\n#### Observed Results:\r\n\r\n  * In my case, the message given above is not received. Is there any mistake in it?\r\n  * It seems that the message is received by the device as I see the following messages:   \r\n\r\n    ```\r\n    07-18 15:28:34.371 3068-3068/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.google.firebase.quickstart.fcm (has extras) }\r\n```\r\n  \r\n#### Expected Results:\r\n\r\n  * The message should be received and generate a notification the application is in foreground or in background.\r\n  \r\n#### Relevant Code:\r\n\r\nMy FirebaseMessagingService is:\r\n\r\n    public class MyFirebaseMessagingService extends FirebaseMessagingService {\r\n    \r\n        private static final String TAG = \"MyFirebaseMsgService\";\r\n    \r\n        /**\r\n         * Called when message is received.\r\n         *\r\n         * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.\r\n         */\r\n        // [START receive_message]\r\n        @Override\r\n        public void onMessageReceived(RemoteMessage remoteMessage) {\r\n            // [START_EXCLUDE]\r\n            // There are two types of messages data messages and notification messages. Data messages are handled\r\n            // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type\r\n            // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app\r\n            // is in the foreground. When the app is in the background an automatically generated notification is displayed.\r\n            // When the user taps on the notification they are returned to the app. Messages containing both notification\r\n            // and data payloads are treated as notification messages. The Firebase console always sends notification\r\n            // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options\r\n            // [END_EXCLUDE]\r\n    \r\n            // TODO(developer): Handle FCM messages here.\r\n            // Not getting messages here? See why this may be: https://goo.gl/39bRNJ\r\n            Log.i(TAG, \"From: \" + remoteMessage.getFrom());\r\n            Log.i(TAG, \"Notification Message Body: \" + remoteMessage.getData());\r\n    \r\n            sendNotification(\"FCM message received\");\r\n\r\n            // Also if you intend on generating your own notifications as a result of a received FCM\r\n            // message, here is where that should be initiated. See sendNotification method below.\r\n        }\r\n        // [END receive_message]\r\n    \r\n        /**\r\n         * Create and show a simple notification containing the received FCM message.\r\n         *\r\n         * @param messageBody FCM message body received.\r\n         */\r\n        private void sendNotification(String messageBody) {\r\n            Intent intent = new Intent(this, MainActivity.class);\r\n            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r\n            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,\r\n                    PendingIntent.FLAG_ONE_SHOT);\r\n    \r\n            Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);\r\n            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)\r\n                    .setSmallIcon(R.drawable.ic_stat_ic_notification)\r\n                    .setContentTitle(\"FCM Message\")\r\n                    .setContentText(messageBody)\r\n                    .setAutoCancel(true)\r\n                    .setSound(defaultSoundUri)\r\n                    .setContentIntent(pendingIntent);\r\n    \r\n            NotificationManager notificationManager =\r\n                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);\r\n    \r\n            notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());\r\n        }\r\n    }\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/firebase/quickstart-android/issues/comments/238357992","html_url":"https://github.com/firebase/quickstart-android/issues/89#issuecomment-238357992","issue_url":"https://api.github.com/repos/firebase/quickstart-android/issues/89","id":238357992,"user":{"login":"kroikie","id":2370200,"avatar_url":"https://avatars.githubusercontent.com/u/2370200?v=3","gravatar_id":"","url":"https://api.github.com/users/kroikie","html_url":"https://github.com/kroikie","followers_url":"https://api.github.com/users/kroikie/followers","following_url":"https://api.github.com/users/kroikie/following{/other_user}","gists_url":"https://api.github.com/users/kroikie/gists{/gist_id}","starred_url":"https://api.github.com/users/kroikie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kroikie/subscriptions","organizations_url":"https://api.github.com/users/kroikie/orgs","repos_url":"https://api.github.com/users/kroikie/repos","events_url":"https://api.github.com/users/kroikie/events{/privacy}","received_events_url":"https://api.github.com/users/kroikie/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T19:59:12Z","updated_at":"2016-08-08T19:59:12Z","body":"This issue seems not to be related to the sample so I'm closing it, however feel free to create new issues."}}
{"actor":{"display_login":"kroikie"}}