-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quickstart-android messaging app doesn't receive data messages in background #89
Comments
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,
The message I talk about For example, I just sent it 3 times to the device for demo and I get the following display in logcat:
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 I also see that when I tap on the recent apps button, the following message is displayed:
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! |
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: 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: If you get the result: 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 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:
How can I help you more? |
@2ndGAB Thanks for the logcat info, looks like the fcm sample is being stopped when it is being sent to the background.
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
And these are the same devices I used for months to test my apps. 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.
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 @2ndGAB couple things that you did not mention that might help: After updating to 2.1.2:
|
Hi @kroikie I deactivated instant run |
@2ndGAB hey did you fixed using AS 1.52 ? |
CAN NOT receive a message when app is in background . |
@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:
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 When App is in foreground, Can receive FCM message:
when in background CAN NOT receive Message and log is: |
@2ndGAB |
@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. 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. SO I tested this case, to see. If I'm right, the message should be :
} 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:
} 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: |
@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. |
@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.
Please note that we have not sent "notification" here as we only want the payload to be given. |
Step 1: Are you in the right place?
Step 2: Describe your environment
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.
Steps to reproduce:
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:
Expected Results:
Relevant Code:
My FirebaseMessagingService is:
The text was updated successfully, but these errors were encountered: