quickstart-unity icon indicating copy to clipboard operation
quickstart-unity copied to clipboard

Push messages are not received when app is in background (Android)

Open EVOsparkLP opened this issue 5 years ago • 5 comments

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.2.6
  • Firebase Unity SDK version: 7.1.0
  • Source you installed the SDK: FirebaseMessaging.unitypackage
  • Problematic Firebase Component: Messaging
  • Other Firebase Components in use: none
  • Additional SDKs you are using: none
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: Mono

[REQUIRED] Please describe the issue here:

Data messages are not handled when the app is in background or killed. The quickstart sample is used without any modifications.

Notification handled by app when app is active - OK Notification shown in system tray when app is in background - OK Data messages received when app is in foreground - OK Data messages handled when app in in background - fails

My expectation is that the data message will start the app and the data content can be handled by the app (e.g. to show an incoming video call).

In my assets I do NOT have a Assets/Plugins/Android/libmessaging_unity_player_activity.jar file. According to the docs (https://firebase.google.com/docs/cloud-messaging/unity/client#configuring_an_android_entry_point_activity) this file is needed for the correct background behavior. So this might be the cause for this issue. Does anybody know where to get this file or can anybody confirm that this is the root cause for this issue?

The issue seems to be the same as these ones, which were closed due to inactivity: #799 #799

Steps to reproduce:

Follow the steps from this guide: https://firebase.google.com/docs/cloud-messaging/unity/client#configuring_an_android_entry_point_activity

  1. Open this firebase messaging quickstart sample in Unity 2020.2.6: https://github.com/firebase/quickstart-unity
  2. Add your firebase config files
  3. Add the FirebaseMessaging.unitypackage (SDK is linked in the guideline)
  4. Switch build target to Android - Android resolver gets triggered and runs successfully
  5. Build Android app and run on device

EVOsparkLP avatar Apr 13 '21 20:04 EVOsparkLP

I'm also looking for a way to wake up an app (like Whatsapp- or Discord-Calls) and expected to create it through Firebase Cloud Messaging and followed the steps of the already mentioned guide. The missing .jar-file isn't the problem according to this reply.

But if this .jar-file isn't the problem. What am I missing to perform a wake-up-call like mentioned (Whatsapp / Discord)?

R-Schulze-Velmede avatar Apr 14 '21 12:04 R-Schulze-Velmede

Hi @EVOsparkLP,

Thanks for reporting this. It seems like you're facing an issue similar to Issue #1020 where the notification doesn't appear when the app is in the background.

I'm going to close this ticket as a duplicate for now so that we can funnel discussions through the aforementioned ticket, but please re-open this issue if you have any other question or if your issue is different from the scenario I described.

paulinon avatar Apr 14 '21 16:04 paulinon

Duplicate of #1020

paulinon avatar Apr 14 '21 16:04 paulinon

Hi @paulinon, thanks for your feedback!

I am aware that #1020 is a similar issue, but I think there are some differences: #1020:

  • message with "notification" and "data" is sent. Notification is shown in the system tray but does not open the app when tapped
  • works when app is killed / not working when app is in background

this issue

  • message with only "data" is sent. onMessageReceived is not called and app is not brought to foreground.
  • not working when app is in background or killed

image

Do you think both issues have the same root cause? What they have in common, is that the app is not brought to foreground.

Best regards.

EVOsparkLP avatar Apr 15 '21 10:04 EVOsparkLP

It's possible that the causes of both issues are similar. With that, updates will be provided in #1020 so that further discussions can be funneled in one thread.

paulinon avatar Apr 15 '21 13:04 paulinon