-
Notifications
You must be signed in to change notification settings - Fork 132
Android FCM not waking up #40
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
Comments
This issue does not seem to follow the issue template. Make sure you provide all the required information. |
@dangvohoanganhvn could you please try using sample app to see if it has the same behavior? If you are actually using the sample app, could you describe a bit more of what's the expected behavior and what you actually see happening? Thanks! |
@cynthiajoan Actually, I'm using sample app. The Logs in loop "while (listener.PollMessage(&message))" just printed on Logcat when I start the app. Is there some C++ API that will be called when my device receive a notification ? I tested Java code and it worked well (see in the attached picture) , the function onMessageReceived will be called when my device receive a notification.Thanks! |
I believe what you meant was: when you put the app in the background, not killed the app, you can still received the push notification. However, the app did not "wake up" and the listener you added through C++ API was not triggered. Is that what you mean? TL; DR; If so, I think it is an intended behavior. In your scenario, you should still receive cached If you need to process the message immediately when the device receive a message, the only way is thru what you are doing right now, override a ListenerService in Java. Here is more detail about it. And again, ListenerService will not receive messages with notification data, as described above. Also, ListenerService is an Android service, which is different from your app, which is an Android activity. You cannot wake your app from a service, AFAIK. And the default behavior of this ListenerService would actually cache received message and makes them available when your app is back to foreground again. This is just a result of the design of Android SDK, which make the event only available in a service, and the design of C++ SDK, where we want the event to be available in an app, e.g. an Android Activity. In conclusion, if you don't need to process the message immediately, but still want to trigger the C++ event when the user clicks on the notification from the system tray, the most general solution is by, again, modifying Activity. Hope this helps! Shawn |
Hi Shawn, Thanks for your help! However, my expectation is that, when my application was killed ,it can receive the notification and call onMessage() C++ function without opening my application and user actions. What should I do? Please give me some helps. |
It is basically impossible by design. When your app is killed or stay in the background for way too long, the only way to wake your app is through Intent. Take a look of this doc. That means you would need to implement your own FirebaseMessageService and start the activity with the Intent. From your app side, you would need to specify which Intent your app is listening to in AndroidManifest.xml. And you will need to process the Intent from your app when it is awake. All these work still won't trigger OnMessage() function in C++. We don't do this in C++ SDK because we do not want to launch the app everytime when the device receives a cloud message. Think about the chaos. 😂 May I learn why you need to process the message immediately even when the app is killed? |
correction I think Android stop allowing you to start an activity from a service. That is in general a very bad idea to do so. If you really need to do something about the message immediately, you can extend ListenerService or FirebaseMessageService directly, like what you did here. But you also run into the limited about different types of message.. |
Hey @dangvohoanganhvn. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @dangvohoanganhvn if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Hi team,
I'm using Firebase C++ SDK quick start messaging to get familiar with Android FCM. After I set up completely, Although I can receive notifications from server, quick start messaging app did not wake up. How can I solve this problem. Thanks.
Platform: Android (built by MAC OS)
Device: Samsung J7
Firebase C++ SDK version: 6.8
The text was updated successfully, but these errors were encountered: