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