quickstart-android messaging app doesn't receive data messages in background

Created on 18 Jul 2016  Â·  79Comments  Â·  Source: firebase/quickstart-android

Step 1: Are you in the right place?

  • Issues related to the code in this repository.

    Step 2: Describe your environment

  • Android device: Asus Nexus 7 wifi

  • Android OS version: 6.0.1
  • Google Play Services version: 3.0.0
  • Firebase/Play Services SDK version: 9.2.1

But I cannot get it working on Nexus 7 LTE 6.0.1 or Samsung GT-9295 5.0.1 as well.

Step 3: Describe the problem:

I 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.

{
    "to" : "egu9jGiMcew:APA91bFv2RewdzlrC4Q0 ... dYZgv91oZVfTtrfAojLMKZZmEURvbq-aA2",
    "data": {
        "title": "Title test",
        "msg": "Text of the test",
        "code": 2
    },
    "delay_while_idle" : false,
    "priority" : "high",
    "content_available" : true
}

Steps to reproduce:

  1. Build the quickstart-android project
  2. Execute the messaging app
  3. Send it a data message when the application is in background

    Observed Results:

  • In my case, the message given above is not received. Is there any mistake in it?
  • It seems that the message is received by the device as I see the following messages:

    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) }
    

    Expected Results:

  • The message should be received and generate a notification the application is in foreground or in background.

    Relevant Code:

My FirebaseMessagingService is:

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = "MyFirebaseMsgService";

    /**
     * Called when message is received.
     *
     * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
     */
    // [START receive_message]
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        // [START_EXCLUDE]
        // There are two types of messages data messages and notification messages. Data messages are handled
        // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
        // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
        // is in the foreground. When the app is in the background an automatically generated notification is displayed.
        // When the user taps on the notification they are returned to the app. Messages containing both notification
        // and data payloads are treated as notification messages. The Firebase console always sends notification
        // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
        // [END_EXCLUDE]

        // TODO(developer): Handle FCM messages here.
        // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
        Log.i(TAG, "From: " + remoteMessage.getFrom());
        Log.i(TAG, "Notification Message Body: " + remoteMessage.getData());

        sendNotification("FCM message received");

        // Also if you intend on generating your own notifications as a result of a received FCM
        // message, here is where that should be initiated. See sendNotification method below.
    }
    // [END receive_message]

    /**
     * Create and show a simple notification containing the received FCM message.
     *
     * @param messageBody FCM message body received.
     */
    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 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_stat_ic_notification)
                .setContentTitle("FCM Message")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }
}

Most helpful comment

The issue here is a result of some devices prematurely closing applications when they are swiped from the recents view. We are working with device makers to ensure that they are correctly handling dismissal from the recents view. This is not an FCM specific issue, GCM will be affected in the same way.

If your app is in the background you should receive data messages in the onMessageReceived callback and notification messages would result in a displayed notification. If you want to highly customize the notification that is shown then you should use data messages and handle the notification creation on the device side.

All 79 comments

  1. Could you clarify how you are placing the app into the background? Eg: Are you tapping the device's home button?
  2. I'm assuming that when you say "Advanced REST Client" you are referring to the FCM REST API. If this is not the case please state more clearly.
  3. In your description of your environment you indicate a Nexus 7 wifi, then you say you are not able to get things working on the Nexus 7 LTE and the Samsung GT-9295

Note: The error you are seeing is usually associated with an application that has been forced stopped in which case it cannot respond to incoming notifications. However if you are getting this error without the application being forced stopped then it will require some further investigation.

@jtushar53 your input here would also be appreciated, if this is indeed a duplicate of your background issue.

I have same problem... cannot able to handle notification when app is in background. It is handled by system tray.

Hello,

  1. I tap the recent apps button then swipe the application out of the recent application list
    I currently have an application published which perfectly receives GCM/FCM messages in this state via onMessageReceive().
  2. I mean Google Advanced REST client which sends the message to https://fcm.googleapis.com/fcm/send
  3. Yes that's not a device or OS version specific issue.

The message I talk about W/GCM-DMM... is displayed in the log window just after I send a message to the device and everytime I send it to the device.

For example, I just sent it 3 times to the device for demo and I get the following display in logcat:

07-19 08:21:14.691 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) }
07-19 08:21:16.480 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) }
07-19 08:21:18.934 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) }

So I don't think my application has been stopped three times successively but I think that the system cannot call the application for any reason. Does what was called receiver in GCM and now handled by the library still works anymore as expected?

I also see that when I tap on the recent apps button, the following message is displayed:

07-19 08:48:57.656 32267-32267/com.my.example D/FirebaseApp: Notifying background state change listeners.

But to be honest, I wonder if the problem only comes from FCM because if I start from my own project which worked few weeks ago and rebuild it, I cannot get it working anymore. But I had many updates suggested by Android through the studio. I currently use Studio 2.1.2, build tools 24.0.0

What really disturb me is the blur about this functionality everywhere including in the doc as if the ability to send data messages to a background/stopped (as you want) application was just discovered last night!
But almost all applications such as client mail, news, etc..., work like that no??

Hii,

for me tested other devices inlcuding Moto G edition and One Plus 2 it is working and on Mi5 it is not working, was getting same error.

Updated:
@kroikie application was not force close just swiped away from recents tray, also if i just press home button(app is minimise) it i am able to see notification in notification tray.

After googling a bit looks like lots of mi5 users are getting this issue from http://en.miui.com/thread-268224-1-1.html and http://en.miui.com/thread-272403-1-1.html , tried that but no luck.

This error is seen when your application has been forced stopped.

Using the command:
adb shell dumpsys package | grep stopped

If you get the result:
User 0: installed=true hidden=false stopped=false notLaunched=false enabled=0
Then since stopped is false your app should get the notification. If however your result is:
User 0: installed=true hidden=false stopped=true notLaunched=false enabled=0
Then since stopped is true your app cannot be started to handle the incoming message.

Could you check if when you remove the app from the recents list or just pause the app by hitting the home button, what the status of your app is? stopped=true or stopped=false?

The expectation is that when you swipe an app from recents the stopped value should still be false, but some launchers are not adhering to this, so if you can confirm the status of your app we can narrow down the issue.

Hello @kroikie
Sorry for the late reply.
The command
adb shell dumpsys package | grep stopped

tells me the following message, the application running or not:

Can't find service: com.google.firebase.quickstart.fcm

For information, when I put your application in background, I get the following log:

                                                    --------- beginning of system
07-22 12:28:00.591 671-745/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher} from uid 10024 on display 0
07-22 12:28:00.630 671-3321/? I/ActivityManager: Killing 17165:com.google.firebase.quickstart.fcm/u0a293 (adj 9): remove task
07-22 12:28:00.656 671-31254/? D/GraphicsStats: Buffer count: 4
07-22 12:28:00.656 671-745/? I/WindowState: WIN DEATH: Window{2349355 u0 com.google.firebase.quickstart.fcm/com.google.firebase.quickstart.fcm.MainActivity}
07-22 12:28:01.011 745-745/? W/Binder_2: type=1400 audit(0.0:13166): avc: denied { ioctl } for path="socket:[2808607]" dev="sockfs" ino=2808607 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
07-22 12:28:01.011 745-745/? W/Binder_2: type=1400 audit(0.0:13167): avc: denied { ioctl } for path="socket:[2808607]" dev="sockfs" ino=2808607 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
07-22 12:28:01.579 3723-3958/? W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
07-22 12:28:01.579 3723-3958/? W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
07-22 12:28:01.660 17340-17340/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
07-22 12:28:01.669 17340-17340/? D/AndroidRuntime: CheckJNI is OFF
07-22 12:28:01.707 27646-27659/? D/==FindMyPhone==: 1469183281707
07-22 12:28:01.752 17340-17340/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
07-22 12:28:01.819 17340-17340/? I/Radio-JNI: register_android_hardware_Radio DONE
07-22 12:28:01.857 17340-17340/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
07-22 12:28:01.860 671-745/? I/ActivityManager: Force stopping com.google.firebase.quickstart.fcm appid=10293 user=0: from pid 17340
07-22 12:28:01.865 17340-17340/? D/AndroidRuntime: Shutting down VM
07-22 12:28:01.867 201-201/? D/NuPlayerDriver: stop(0xb3d2b6c0)
07-22 12:28:01.867 201-201/? D/NuPlayerDriver: notifyListener_l(0xb3d2b6c0), (8, 0, 0)
07-22 12:28:01.869 3032-2494/? W/MessageQueue: Handler (android.media.MediaPlayer$EventHandler) {2d81fea} sending message to a Handler on a dead thread
                                               java.lang.IllegalStateException: Handler (android.media.MediaPlayer$EventHandler) {2d81fea} sending message to a Handler on a dead thread
                                                   at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
                                                   at android.os.Handler.enqueueMessage(Handler.java:631)
                                                   at android.os.Handler.sendMessageAtTime(Handler.java:600)
                                                   at android.os.Handler.sendMessageDelayed(Handler.java:570)
                                                   at android.os.Handler.sendMessage(Handler.java:507)
                                                   at android.media.MediaPlayer.postEventFromNative(MediaPlayer.java:2988)
07-22 12:28:01.869 201-698/? D/NuPlayerDriver: reset(0xb3d2b6c0)
07-22 12:28:01.876 201-17250/? W/AMessage: failed to post message as target looper for handler 0 is gone.
07-22 12:28:01.879 201-17250/? D/NuPlayerDriver: notifyResetComplete(0xb3d2b6c0)

How can I help you more?
Didi you verified if you are able to send message to your quickstart-android messaging app from your side?

@2ndGAB Thanks for the logcat info, looks like the fcm sample is being stopped when it is being sent to the background.

07-22 12:28:01.860 671-745/? I/ActivityManager: Force stopping com.google.firebase.quickstart.fcm appid=10293 user=0: from pid 17340

I'm not sure why Activity Manager is killing the sample app when you put it in a background state. This is not expected behaviour, what device are you trying this one? Some devices have restrictions on what applications can be run in the background, I'm wondering if your device is stopping some apps when swiped from recents and not others.

Hi @kroikie
I tried on a Nexus 7 6.0.1
So I tried on a GT-9295 5.0.1 and I get the same result:

07-23 20:16:34.620 803-1408/? I/ActivityManager: Force stopping com.google.firebase.quickstart.fcm appid=10317 user=0: from pid 7231
07-23 20:16:34.620 803-1408/? I/ActivityManager:   Force stopping service ServiceRecord{3cada6f8 u0 com.google.firebase.quickstart.fcm/.MyFirebaseMessagingService}

And these are the same devices I used for months to test my apps.
If the Nexus has been regularly updated, this is not the question of the GT9295/5.0.1 so no reason to doubt on them.

that's really incredible.

I tried to rebuild an old working project of mine with sdk 23, GCM 8.4.0, java 1.7, so the environment I got working project with and I cannot get a working application anymore!

The only differnece I see now is the version of Android-studio/gradle.

Could please tell me if you build working projects with the last development environment updates???

THAT'S COMPLETELY INCREDIBLE

I've reisntalled Android Studio 1.5 bundle 141.2422023, sdk 23.0.3, java jdk1.7.0_79 and rebuilt your application.

The result is amazing. I don't have the Force Stopping message anymore when I put the application in background.

07-24 12:00:10.409 671-3321/? I/ActivityManager: Killing 11067:com.google.firebase.quickstart.fcm/u0a297 (adj 9): remove task
07-24 12:00:10.425 671-31254/? D/GraphicsStats: Buffer count: 4
07-24 12:00:10.425 671-31254/? I/WindowState: WIN DEATH: Window{996cbf7 u0 com.google.firebase.quickstart.fcm/com.google.firebase.quickstart.fcm.MainActivity}

And, it correctly receives and processes the data message in background

messaging app has been successfully rebuilt under Studio 1.5.2 with sdk 24, buildtools 24.0.0, and java 1.8.0_92

Please Please Pleasssssssseeeeeeeee tell me what's wrong !!!!!!

@2ndGAB thanks for the information, we do test our samples against the latest developer environments. I don't think that you are doing anything wrong here, it is very unusual what you are experiencing. I'm looking into it and will reply here with more. If you can, in the meantime, use AS 1.5.2.

Hi @2ndGAB there should be no change affecting the build between AS 1.5 and 2.1, could you confirm that you are not changing anything in the messaging quickstart? As in git status does not indicate any changes?

Hi @kroikie

OOOOOOOHHHHHHHHHHHHH YESSSSSSS!!!

Please have a look at my complete tests here

;-/

Regards,

Hi @2ndGAB couple things that you did not mention that might help:

After updating to 2.1.2:

  • were you using instant run?
  • did you clean the project?
  • did you try building the project from the command line? From the project directory:

.\gradlew.bat :app:assembleDebug

Hi @kroikie

I deactivated instant run
Yes of course I cleaned/rebuilt many times/
But I didn't try to built it from command line.
I'll test it.

@2ndGAB hey did you fixed using AS 1.52 ?

CAN NOT receive a message when app is in background .
D/FirebaseApp: Notifying background state change listeners.
W/FirebaseMessaging: Unable to log event, missing measurement library

@yucheng82 First check if your device receives the message. Have a look at the logcat view and see if you receive such kind of messages:

mm-dd hh:ii:ss.nnn 1461-1461/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.your.package (has extras) }

If no, maybe you don't use the right token.

If yes, please tell me what Android Studio version do you use.

@Nicomalacho Yes, definitively, as explained in detail here

@2ndGAB
My Android Studio is 2.1.2
message lib version:
com.google.firebase:firebase-messaging:9.2.1
My App token is ok .

When App is in foreground, Can receive FCM message:

D/MyFirebaseMsgService: From: 568540028909
D/MyFirebaseMsgService: Message Notification Body: Test Message

when in background CAN NOT receive Message and log is:
W/FirebaseMessaging: Unable to log event, missing measurement library

@2ndGAB
I find when APP is in background the FCM message is show by notification , not send message to my APP.
and when message is stop, noting is received.
How can i receive a message when app is in background and app is not running.
Thanks!

@yucheng82 so to see if you are facing the same problem as me, I can advise you to install Android Studio 1.5 from here.

Install it in a different folder so you keep 2.1.2 version.
You can specify a different sdk folder as well but in fact, the problem seems not coming from it.

Then you open your project in AS 1.5, without changing anything except if you swithed to Java 1.8. You will have to come back to 1.7.

Build your project and verify if now you receive data message in background...

Just a precision, I as working with data message only, not notification + data messages.
It seems it's what you use.

SO I tested this case, to see. If I'm right, the message should be :

{
  "to" : "ff7dwHxWZeE:APA91bFbzYFqFKUwYW...c_1TfunYKKYXcjiX5a",
   "notification": {
     "title": "just a test",
       "msg": "Just to verify"
   }
  "data": {
    "id": 19,
    "title": "Title test",
    "msg": "Text of the test",
    "code": 2,
    "infosUrl": "http://www.example.com",
    "longitude": 5.5,
    "latitude": 44.5,
    "eventLocation": "nowhere",
    "startDate": "31/07/2016 20:00",
    "endDate": "31/07/2016 22:00",
    "publishEndDate": "31/07/2016 20:00"
  }
  "content_available": true

}

In that case, when the application is in foreground, the application receives the data and when the application is in background, the system receives the notification.

So, to be sure that your application receives a data message in foreground AND in background, you need to send a DATA ONLY message like below:

{
  "to" : "ff7dwHxWZeE:APA91bFbzYFqFKUwYW...c_1TfunYKKYXcjiX5a",
  "data": {
    "id": 19,
    "title": "Title test",
    "msg": "Text of the test",
    "code": 2,
    "infosUrl": "http://www.example.com",
    "longitude": 5.5,
    "latitude": 44.5,
    "eventLocation": "nowhere",
    "startDate": "31/07/2016 20:00",
    "endDate": "31/07/2016 22:00",
    "publishEndDate": "31/07/2016 20:00"
  }
  "content_available": true

}

AFAIK, firebase console is not able to send such message, so you need to use the API mode with Google Advanced REST Client

@yucheng82 are you seeing this behaviour while running this sample? The warning you are mentioning about the missing measurement library should not prevent your app from receiving the message, that is just an indication that the automatic analytics provided by FCM will not work.

@2ndGAB I'm not convinced that the issue you are facing is due to an Android Studio version change, nor am I convinced that it is the issue being faced by @yucheng82. All Android Studio is doing is executing kicking off the build eg: ./gradlew :app:assembleDebug so there should not be anything in Android Studio itself that would affect the built APK of your application. I understand that it looks like Android Studio to you, and it may be, but I'd suggest trying building from the command line first and seeing if the issue persists.

@kroikie maybe but did you have a look at all tests I made here ?

  • So I tried to build from the Android Studio 1.5 terminal and here is what has been done:

C:\Users\me\Documents\GitHub\MyApp>.\gradlew.bat :app:assembleDebug
Downloading https://services.gradle.org/distributions/gradle-2.10-all.zip
............................
Unzipping C:\Users\me.gradle\wrapper\dists\gradle-2.10-all\5b6kqrscumh9p4evkkemdk57ad\gradle-2.10-all.zip to C:\Users\me.gradle\wrapper\dists\gradle-2.10-all\5b6kqrscumh9p4evkkemdk57ad
Download https://jcenter.bintray.com/org/ow2/asm/asm/5.0.3/asm-5.0.3.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/5.0.3/asm-parent-5.0.3.pom
Download https://jcenter.bintray.com/org/ow2/ow2/1.3/ow2-1.3.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.2.1/proguard-gradle-5.2.1.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-parent/5.2.1/proguard-parent-5.2.1.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.core/0.7.4.201502262128/org.jacoco.core-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.build/0.7.4.201502262128/org.jacoco.build-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/antlr/antlr/3.5.2/antlr-3.5.2.pom
Download https://jcenter.bintray.com/org/antlr/antlr-master/3.5.2/antlr-master-3.5.2.pom
Download https://jcenter.bintray.com/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
Download https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.pom
Download https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.pom
Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.pom
Download https://jcenter.bintray.com/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4/4.5/antlr4-4.5.pom
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4-master/4.5/antlr4-master-4.5.pom
Download https://jcenter.bintray.com/commons-io/commons-io/2.4/commons-io-2.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/25/commons-parent-25.pom
Download https://jcenter.bintray.com/org/apache/apache/9/apache-9.pom
Download https://jcenter.bintray.com/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.2.1/proguard-base-5.2.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/5.0.1/asm-parent-5.0.1.pom
Download https://jcenter.bintray.com/org/antlr/antlr-runtime/3.5.2/antlr-runtime-3.5.2.pom
Download https://jcenter.bintray.com/org/antlr/ST4/4.0.8/ST4-4.0.8.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.1.1/httpcomponents-client-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/project/4.1.1/project-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.1/httpcomponents-client-4.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.pom
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4-runtime/4.5/antlr4-runtime-4.5.pom
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4-annotations/4.5/antlr4-annotations-4.5.pom
Download https://jcenter.bintray.com/com/intellij/annotations/12.0/annotations-12.0.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-core/4.1/httpcomponents-core-4.1.pom
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/5/commons-parent-5.pom
Download https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/11/commons-parent-11.pom
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.pom
Download https://jcenter.bintray.com/org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.2.1/proguard-gradle-5.2.1.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.core/0.7.4.201502262128/org.jacoco.core-0.7.4.201502262128.jar
Download https://jcenter.bintray.com/org/antlr/antlr/3.5.2/antlr-3.5.2.jar
Download https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar
Download https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar
Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.jar
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4/4.5/antlr4-4.5.jar
Download https://jcenter.bintray.com/commons-io/commons-io/2.4/commons-io-2.4.jar
Download https://jcenter.bintray.com/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.2.1/proguard-base-5.2.1.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.jar
Download https://jcenter.bintray.com/org/antlr/antlr-runtime/3.5.2/antlr-runtime-3.5.2.jar
Download https://jcenter.bintray.com/org/antlr/ST4/4.0.8/ST4-4.0.8.jar
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
Download https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.jar
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4-runtime/4.5/antlr4-runtime-4.5.jar
Download https://jcenter.bintray.com/com/tunnelvisionlabs/antlr4-annotations/4.5/antlr4-annotations-4.5.jar
Download https://jcenter.bintray.com/com/intellij/annotations/12.0/annotations-12.0.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.jar
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar
Download https://jcenter.bintray.com/org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1.jar
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2411Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72411Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72340Library UP-TO-DATE
:app:prepareComAndroidSupportCustomtabs2340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42411Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2411Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk4140Library UP-TO-DATE
:app:prepareComGithubMKergallOsmbonuspackV581Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing921Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase921Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement921Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation921Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks921Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalytics921Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl921Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommon921Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCore921Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIid921Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseMessaging921Library UP-TO-DATE
:app:prepareMeDm7BarcodescannerCore184Library UP-TO-DATE
:app:prepareMeDm7BarcodescannerZxing184Library UP-TO-DATE
:app:prepareOrgOsmdroidOsmdroidAndroid52Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: C:\Users\me\Documents\GitHub\MyApp\app\google-services.json
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\me\Documents\GitHub\MyApp\app\src\main\java\com\my\package\Fragment_downloadMaps.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug
Result compacted from 8326,4KiB to 6356,0KiB to save 1970,4KiB
Merged dex #1 (15 defs/26,9KiB)
Merged dex #2 (36 defs/34,3KiB)
Merged dex #3 (5 defs/15,3KiB)
Merged dex #4 (355 defs/574,2KiB)
Merged dex #5 (13 defs/22,9KiB)
Merged dex #6 (21 defs/21,2KiB)
Merged dex #7 (819 defs/997,1KiB)
Merged dex #8 (17 defs/48,5KiB)
Merged dex #9 (558 defs/621,0KiB)
Merged dex #10 (80 defs/147,1KiB)
Merged dex #11 (81 defs/68,0KiB)
Merged dex #12 (265 defs/237,9KiB)
Merged dex #13 (530 defs/522,3KiB)
Merged dex #14 (109 defs/90,5KiB)
Merged dex #15 (29 defs/20,5KiB)
Merged dex #16 (3 defs/3,6KiB)
Merged dex #17 (115 defs/202,5KiB)
Merged dex #18 (22 defs/23,4KiB)
Merged dex #19 (15 defs/33,5KiB)
Merged dex #20 (10 defs/22,6KiB)
Merged dex #21 (110 defs/178,4KiB)
Merged dex #22 (217 defs/459,2KiB)
Merged dex #23 (177 defs/288,0KiB)
Merged dex #24 (264 defs/481,2KiB)
Merged dex #25 (289 defs/589,8KiB)
Merged dex #26 (165 defs/171,2KiB)
Merged dex #27 (363 defs/280,8KiB)
Merged dex #28 (12 defs/19,4KiB)
Merged dex #29 (4 defs/7,1KiB)
Merged dex #30 (175 defs/299,9KiB)
Merged dex #31 (34 defs/67,9KiB)
Merged dex #32 (201 defs/282,5KiB)
Merged dex #33 (46 defs/7,4KiB)
Result is 5155 defs/6356,0KiB. Took 0,7s
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug

BUILD SUCCESSFUL

And I installed the resulting package

adb -s xxxxxxx install .\app\build\outputs\apk\app-debug.apk

And the application receives data message in background.

  • Then I tried the same from Android Studio 2.1.2 terminal:

And I installed the resulting package

adb -s xxxxxxx install .\app\build\outputs\apk\app-debug.apk

And the application receives data message in background.

  • Then I tried to rebuild/install the app from Android Studio 2.1.2 ide

And the application _DOES NOT_ receive data message in background.

Anyway, what I see from my side is the development environment installed by Android Studio and everything installed to build an application from the source code.
And the tests I made prove that something installed beside sdk, build-tools and Java modify the build.

How can we conclude something else?

There is something which would really interest me, this is to know if for you, sending a data message it to your messaging app really works when built from the latest dev env.
And if yes, why that point is not clearly explained in the doc?

@2ndGAB could you try uninstalling both versions of Android Studio and building from the command line like you have done here and see if the issue persists?

@kroikie but as you can see, that doesn't depend on sdk and build tools, so I'll be in one of the 2 first cases i.e. building from the command line and building from command line seems to work without problem.
Again, the problem comes if I launch the build from Android Studio 2.
So what do you expect to see more?

@2ndGAB Sorry miss read your post, could you try the 2.2 preview, if there is an issue in 2.1 it may have already been fixed.

ok I'll try

So, I've installed AS 2.2 Preview 7, I installed evertyhing, I didn't import the settings from AS 2.1

I rebuilt my project, same problem!

I've upgrade my project to 9.4.0, same problem!

I Have same problem,
I use AS 2.1.2 and AS 2.2 Preview 7
Use Target and Compiled SDK API 24
Use Device Xiaomi Redmi Note 3

problem is
if i'm launched app, i can received noification with onMessageReceived()
if i'm press home button / back button in main activity, i can received notification with default FCM
if i'm kill this app, i cant received notification but get usefull message

W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.......

i dont know what must i do. my code same as fcm example quickstart.

@mindfreak269 do you talk here about notification message or data message?

@kroikie @anujjpandey11
Hi I faced into the same issue.
My app is built in Android 2.1.2.
My app receive the FCM notification with Android service extending the FirebaseMessagingService
Although it's not working when my app is clear from the background

There are some questions I am curious about

1.why my app is using 'service' but not 'receiver' in Manifeset.xml
2.is there any problem with FCM ? Since it worked few days ago.

P.S. I added key "notification" and "data" in my sending message .PHP

@MiniJay if you send notification+data message, your application is not supposed to receive it when it's in background. Only the system tray receives it. But in that case, when you tap the notification, your application is supposed to be launched and receives the data through the intent.

From Firebase messaging

Messages with both notification and data payloads
App behavior when receiving messages that include both notification and data payloads depends on whether the app is in the background or the foreground—essentially, whether or not it is active at the time of receipt.
When in the background, apps receive the notification payload in the notification tray, and only handle the data payload when the user taps on the notification.
When in the foreground, your app receives a message object with both payloads available.

If you want your application receives data while in background, you need to send a data only message.

hi @2ndGAB,
I got data from from Intent throw: intent.getStringExtra("ll"). Is it proper way to get data from received intent?

Thanks!

@lenguyenthanh I would prefer to let @kroikie to answer that point as I didn't explore this feature again from my side.

@2ndGAB so, if i'm using firebase console, i cant get the message because no option like that, only rest advance API maybe can do that.
@MiniJay i agree with you, why must service, service can killed with MUI (Xiaomi OS in my case), different with GCM, it have receiver and no problem when app killed,

@MiniJay

  1. Firebase add the necessary receivers to your manifest at build time. If you look at the merged manifest of your application you will see a receiver for com.google.firebase.iid.FirebaseInstanceIdReceiver this serves both the FirebaseMessagingService and the FirebaseInstanceIDService.
  2. There is currently no know issues with the FCM service see the status dashboard.

@lenguyenthanh you are retrieving the data correctly, however be sure to check that the intent extra exists since sometimes the intent may be fired without those extras.

@mindfreak269 what you are seeing is working as intended, if the app is killed by the user the expectation is that it should not be restarted without their explicit indication (by launching the app) that they want the app to run. Thus if your app is killed it should not receive FCM messages. From docs:

Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications.

@2ndGAB I will take your issue back to the Android Studio team. What platform are you running AS on?

This issue seems not to be related to the sample so I'm closing it, however feel free to create new issues.

Thanks @kroikie for answering my question :)

@kroikie on Windows 10 Professional Edition.
To resume, I currently use AS 1.5 without any problem, I can build/start your projet and mine from the IDE (I mean from the debug button) and I onMessageReceive() is fired for data message in foreground and background.

From AS 2.1 and 2.2, I can get a working project if I build/install the application from the terminal as you suggested to me. BUT if I build/install the application from the IDE, data message don't fire onMessageReceive() whe the app is in background.

All details of my tests are here

Thanks @2ndGAB to be clear are you saying that any project built with AS 2.1 or later causes the app to be stopped once it is removed from recents menu?

@kroikie At least I can say that I have the exact same behavior on your project and mine.

Is this issue fixed? Updated today to FCM and fasted the remaining time to debug this. If I see it right you can't receive notification messages with data in background anymore. This is more or less intended. Please confirm. If so do we need to stay with GCM? Is an update / fix planned? As this breaks the behaviour. It seems their is no way to get rid of the default notification message and so also no way to add custom behavior with button nor custom look an feel in the notification. Even i18n needs to be done one the server now too.

The issue here is a result of some devices prematurely closing applications when they are swiped from the recents view. We are working with device makers to ensure that they are correctly handling dismissal from the recents view. This is not an FCM specific issue, GCM will be affected in the same way.

If your app is in the background you should receive data messages in the onMessageReceived callback and notification messages would result in a displayed notification. If you want to highly customize the notification that is shown then you should use data messages and handle the notification creation on the device side.

@sterlp I would like to trust @kroikie but from my side, I'm still thinking that devices are not -only- in cause here. Since I choosed to keep using Android Studio 1.5, I didn't notice any problem anymore but of course, I cannot make tests with enough different devices.
Maybe I could check if I can reach all installed application, at least on and Android because iOS is again a different problem. I haven't so much time at the moment but I'll try to think about it. I wonder if it's possible...

It seems that my hypothesis is not really considered serioulsy, but if you have time, just try to build your app with AS 1.5 and test it on the devices which cause problem, to see....

https://code.google.com/p/android/issues/detail?id=

Maybe also try to build your app from command line because AFAIR, I made this test on @kroikie's advice and it seems working, but not really comfortable in the IDE.

I can confirm the crash of the App with click_action set in the Notification. I added the intents to the activities. On click nothing happens. I can see in the IDE a background crash of the app.

Build tools 24.0.0
FCM 9.6.1
Android Studio 2.2.1
Android 6 and Android 5.1

using a data message only works as expected -- basically like with GCM, of course the notification is missing.

// disclamer as new bug
Furthermore Color & ICON doesn't work together. My color is white and the icon is displayed okay on top left, if I open the notification center it is just white, message and title works at least.
default Sound isn't played.

Just to add that for me the problem is solved in Android Studio 2.2.2 145.3360264.

FCM data messages are well received in onMessageReceive() when the app is in background and custom notifications are successfully generated !!! ;-)

With Android Studio >= 2.2 there is an issue displaying notification when app was killed (by swiping away from recent apps). But it's the case just on some devices, presumably on ones that initiate force stop when you swipe the app from recents. AFAIK there is no way to fix this except changing the manufacturing process, so hopefully OEMs will take this issue into consideration.

In android studio 1.5 chances of app getting force killed are lesser than
android studio 2.0.

On Nov 6, 2016 9:35 PM, "vitnuk" [email protected] wrote:

With Android Studio >= 2.2 there is an issue displaying notification when
app was killed (by swiping away from recent apps). But it's the case just
on some devices, presumably on ones that initiate force stop when you swipe
the app from recents. AFAIK there is no way to fix this except changing the
manufacturing process, so hopefully OEMs will take this issue into
consideration.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/firebase/quickstart-android/issues/89#issuecomment-258690540,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAiHzpazjVOkUWN9Y4b5TaaJaFGEfjc9ks5q7frEgaJpZM4JOtXI
.

@codenpk This what I noticed. Now I recently tested it with AS 2.2.2 and I don't have this issue anymore.
Note that I don't use FCM notification or notifications with data-messages but data-messages only.

@2ndGAB I'm using AS 2.2 and data-messages only, it does not work when the app was killed on Lenovo A6010 Pro, but works great on emulators and couple of other devices.

@codenpk I've heard talking about such problems on specific devices. Difficult to guess if that could come from the manufacturer or a possible issue in firebase....

I can confirm the same issue, using this configuration:
devices: Nexus 5 AND Google Pixel,
Firebase dependencies:
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
IDE: Android studio 2.2, stable channel

Log:
Server sends data-only message, but if the app is killed, I get:
broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.whatever (has extras) }

Judging by @2ndGAB I should try newer AS release ?

Hmmm, with this Firebase, each day you learn something extraordinary :)

Updating to latest Android Studio(2.3 beta 1) and accompanying gradle version (as well as buildToolsVersion '25.0.0'), it seem to work as intended, that is, seem to work even if app is
in "swipe to kill" or in background. Will keep tracking this, as a number of customers using our application filed this issue. I'll push a new version to the store and will inform you if this hack really
works for a greater device pool, so we all can close this one and get some sleep.

Hello @miroslavign,
Glad to here that, I arrived to the same conclusion where this feature strangely stopped to work with the first 2.X AS versions.

New issue, will test it more to determine, but we had a complaint from two customers using latest N version (Nexus 6P and Pixel). We will investigate more if this is actually version specific now.

@miroslavign, @kroikie in fact I recently discovered that sometimes, at least because I'm not absolutely sure it's not something new again, data messages are not received when we install a debug apk!!

@2ndGAB tnx for sharing that. I'm gonna concentrate on testing release builds only, but then,
I'm not sure if we're going to be able to see the message:
broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.whatever (has extras) }

@kroikie a question related to making a service go to a new process using
android:process=":remote"

After inserting that line, I get a crash on my service (and it is not running after that):
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.whatever:remote. Make sure to call FirebaseApp.initializeApp(Context) first.

Now, before this, I did not use anything in my background service related to FCM, so, why
and (more importantly) how could I do this in my service ? Initialize what ?
Adding this my service, does not work out of the box:
@Override
public void onCreate() {
FirebaseApp.initializeApp(this);

Any ideas, because, putting my service (which should be always running no matter if app is killed),
may resolve most of the problems our app has, related to FCM missing documentation...

Anyone is having some news about this issue?

I find what seems the same problem.

Android 4.4, firebase:firebase-messaging:10.0.1, AS:2.3 beta 3
We made a little App with an activity and a couple of services. First service is the FCM receptor, second One is a service that we will keep working in foreground with his own notification.

When the activity is running, if the FCM device gets a message, the onMessageReceived is launched as intended.
But if we swipe out the Activity, and the foreground service is still working, when a message is received, the service simply dissapears with a Force stopping message.
Same behavior in android 5 and 5.1, in android 6 and 7 seems to work as intended.

@alcastelo Just to verify something, did you have a look at at some articles upper in this thread related to the Android Studio version if you use it?

Same issue here:

`05-31 15:33:34.493: W/GCM(3435): Mismatched messenger

05-31 15:34:52.593: W/GCM-DMM(3435): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.whatever (has extras) }

05-31 15:34:52.603: W/GCM-DMM(3435): Unregister application com.whatever for user 0`

I'm using AS 2.3.2, JRE: 1.8.0_112., Firebase 10.2.4, device is Samsung Galaxy J5 (SM-J500M) and Android version is 6.0.1

Same issue here https://github.com/phonegap/phonegap-plugin-push/issues/707#issuecomment-309211376:

06-17 13:51:52.028 4952 7647 I SendBroadcastPermission: action:com.google.android.c2dm.intent.RECEIVE, mPermissionType:0
06-17 13:51:52.042 4952 4952 W GCM-DMM : broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=info.larinconadasisepuede.lrssp (has extras) }

I'm using AS 2.3.3 recently updated, device Huawei P8, Android 6.0, EMUI 4.0.1

@2ndGAB
I am using
AS 2.3.3
compile SDK version -25
Support lib version - 25.3.1
Google Play services version -11.0.4

When app is in foreground I get notification with data,
but when an app is in the background or killed notification not received with data,

I get the following logs
W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=packgeName (has extras) }

it works perfectly with notification but I can't customize.
Tested on One plus 5 .OS 7.1.1

finally here is my answer.https://stackoverflow.com/a/45810771/1993001

Have also seen this on a beta Crashlytics build, and I'm positive I had not manually pressed FORCE STOP in app settings. I'm able to repro by going into app settings and force closing the app.

Swiping to close the app does not cause this issue (at least not in my tests).

08-11 11:19:30.900 ? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.my.package (has extras) }

@loeschg what phone model do you use?

@Florin-Birgu Pixel (7.1.2)

I wish I could provide more info, but I'm not able to reproduce the scenario. I did have it happen periodically (~1x a week for a couple months). I haven't seen it for a few weeks now.

Random bits of info that may help correlate a root cause:

  • It often seemed to happen overnight. I'd get pushes right before heading to bed. I'd plug in my phone and wake up and notice I had no push notifications for this app (despite there being activity in the AM)
  • It seemed to happen slightly more frequently Sunday PM -> Monday AM (this may be pure coincidence)
  • Re-opening the app would immediately resolve the issue.

Edit: Also realizing this may not be the proper ticket for this discussion. Arrived here from Google-ing. Let me know if I should open a separate ticket somewhere.

same thing happening with me ,bothering me from week now
this message came when my app is swiped from tray

GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.lifepage.jfh (has extras) }

and so far reading the suggestions above the only solution i got is install android studio 1.5
is this correct or there are other solutions for this problem???

device - oneplus 3t
android studio - 2.3.3
build version - 25.0.3

i tried fcm and gcm both.

log with gcm --

08-14 10:20:58.677 8904-8923/com.lifepage.jfh D/FA: Logging event (FE): session_start(_s), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=TutorialActivity, firebase_screen_id(_si)=-4275405240345914240}]
08-14 10:20:58.699 8904-8923/com.lifepage.jfh V/FA: Using measurement service
08-14 10:20:58.699 8904-8923/com.lifepage.jfh V/FA: Connecting to remote service
08-14 10:20:58.712 8904-8923/com.lifepage.jfh D/FA: Connected to remote service
08-14 10:20:58.712 8904-8923/com.lifepage.jfh V/FA: Processing queued up service tasks: 1
08-14 10:20:58.774 19291-9018/? V/FA-SVC: Event recorded: Event{appId='com.lifepage.jfh', name='session_start(_s)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=TutorialActivity, firebase_screen_id(_si)=-4275405240345914240}]}
08-14 10:21:03.747 8904-8923/com.lifepage.jfh V/FA: Inactivity, disconnecting from the service
08-14 10:22:32.461 8904-10577/com.lifepage.jfh D/GcmNotificationListener: From: 213539449012
08-14 10:22:32.461 8904-10577/com.lifepage.jfh D/GcmNotificationListener: Message: 20170518-0001
08-14 10:22:32.462 8904-10577/com.lifepage.jfh D/GcmNotificationListener: data payload accepted
08-14 10:22:48.557 3486-3486/? D/SystemServicesProxy: getRecentTasks: com.lifepage.jfh
08-14 10:22:48.602 2779-2856/? D/StatusBarManagerService: manageDisableList userId=0 what=0x0 pkg=Window{c7c64b5 u0 com.lifepage.jfh/com.lifepage.jfh.TutorialActivity} token=android.os.Binder@98727f9 which=1
08-14 10:22:48.607 8904-10802/com.lifepage.jfh D/AppTracker: App Event: stop
08-14 10:22:48.610 8904-10803/com.lifepage.jfh V/FA: Recording user engagement, ms: 119948
08-14 10:22:48.611 8904-10803/com.lifepage.jfh V/FA: Using measurement service
08-14 10:22:48.611 8904-10803/com.lifepage.jfh V/FA: Connecting to remote service
08-14 10:22:48.615 8904-10803/com.lifepage.jfh V/FA: Activity paused, time: 1208442468
08-14 10:22:48.618 8904-10803/com.lifepage.jfh D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=119948, firebase_screen_class(_sc)=TutorialActivity, firebase_screen_id(_si)=-4275405240345914240}]
08-14 10:22:48.641 8904-10803/com.lifepage.jfh V/FA: Using measurement service
08-14 10:22:48.641 8904-10803/com.lifepage.jfh V/FA: Connection attempt already in progress
08-14 10:22:48.641 8904-10803/com.lifepage.jfh D/FA: Connected to remote service
08-14 10:22:48.641 8904-10803/com.lifepage.jfh V/FA: Processing queued up service tasks: 2
08-14 10:22:48.708 19291-10804/? V/FA-SVC: Event recorded: Event{appId='com.lifepage.jfh', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=119948, firebase_screen_class(_sc)=TutorialActivity, firebase_screen_id(_si)=-4275405240345914240}]}
08-14 10:22:48.741 3486-3486/? D/SystemServicesProxy: getRecentTasks: com.lifepage.jfh
08-14 10:22:49.664 2779-4232/? I/ActivityManager: Killing 8904:com.lifepage.jfh/u0a212 (adj 900): remove task
08-14 10:22:49.665 2779-4232/? I/ActivityManager: Killing 8956:com.lifepage.jfh:download_queue/u0a212 (adj 904): remove task
08-14 10:22:49.705 2779-3717/? I/WindowManager: WIN DEATH: Window{c7c64b5 u0 com.lifepage.jfh/com.lifepage.jfh.TutorialActivity}
08-14 10:23:04.678 24779-24779/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.lifepage.jfh (has extras) }

Same issue here:
09-20 22:00:29.320 2485-2485/com.google.android.gms.persistent W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=(my package) (has extras) }

I was hoping updating to the lastest libs would fix this, but it does not.
AS 2.3.3
om.google.gms:google-services:3.1.1
com.google.firebase:firebase-messaging:11.0.4

Facing similar issue :
01-31 12:54:57.417: W/GCM-DMM(2638): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=np.ngopal.net.cbts.marcopolo (has extras) }

I am using Android Oreo in Oneplus 3 device. I closed the app by swipping away from task list. But if i have app running behind it will show the notification.

@privatejava This might be helpful for you https://stackoverflow.com/a/45810771/1993001

Thanks @rahuldevanavar91 It worked after i disable the battery optimization even after i cleared from task list.

But I am amazed how are other apps being able to send notification even if i cleared them via task list when i literally have battery optimization enabled.

@privatejava ... if battery optimization is enabled other applications also not receive the notification I cheked this, only WhatsApp notification you will get

@rahuldevanavar91 any idea how WhatsApp is doing it?

@spddheeraj May be they will try to create a background services app once they gets killed manually . So they would always get notification.

Also getting this issue, is there any resolutions at this time?

@privatejava can you help me how to create service running on FirebaseMessagingService?

Why does not SDK call onMessageReceived in background? I can not find a reasonable reason.

I found a related topic stating that we can send only notification messages through Firebase Console. If we want a datapayload message we can send that using Postman.

{
"to" : "token of client",
"collapse_key" : "type_a",
"data" : {
     "body" : "Test",
    "title": "Test",
    "message" : "Test"
}
 }

Please note that we have not sent "notification" here as we only want the payload to be given.
Reference: https://stackoverflow.com/questions/37454501/firebase-fcm-force-ontokenrefresh-to-be-called

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaushikb1996 picture kaushikb1996  Â·  4Comments

hungud picture hungud  Â·  6Comments

DenLangeKilde picture DenLangeKilde  Â·  5Comments

wellbranding picture wellbranding  Â·  3Comments

HanSeungBeom picture HanSeungBeom  Â·  3Comments