quickstart-unity: [Question] Push notification messages are not displayed in the closed/background app on launch

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.10
  • Firebase Unity SDK version: 8.1.0
  • Source you installed the SDK: unitypackage
  • Problematic Firebase Component: Messaging
  • Other Firebase Components in use: Analytics, Deepliinks, Crashlytics,
  • Additional SDKs you are using: Facebook, IronSource
  • Platform you are using the Unity editor on Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the question here:

Push notification messages are not received in the app if the app is either closed or is in the background. The foreground app receives messages OK.

queued message 0:1628115171791201%bfe3fe3bbfe3fe3b
Firebase.AppUtilPINVOKE:PollCallbacks()
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()

and

2021-08-10 00:14:38.207 23350-23465/com.threed_view.FluentWorldsDev E/Unity: Couldn't parse the message: Object reference not set to an instance of an object.
    VIEW.VCT.Common.VCTLog:Error(String, String)
    VIEW.VCT.Common.VCTLog:CatchLogs(String, String, LogType)
    UnityEngine.LogCallback:Invoke(String, String, LogType)
    VIEW.VCT.Common.MessagingService:OnMessageReceived(Object, MessageReceivedEventArgs)
    System.EventHandler`1:Invoke(Object, TEventArgs)
    Firebase.Messaging.<MessageReceivedDelegateMethod>c__AnonStorey0:<>m__0()
    System.Func`1:Invoke()
    Firebase.ExceptionAggregator:Wrap(Func`1, T)
    Firebase.AppUtilPINVOKE:PollCallbacks()
    Firebase.AppUtil:PollCallbacks()
    Firebase.Platform.FirebaseHandler:Update()

2021-08-10 00:01:16.109 20990-21989/com.threed_view.FluentWorldsDev W/FirebaseMessaging: Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.

So I guess I somehow missing on queued message handling when app is launched?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@equizo

I tried to reproduce it with the following configuration, but I can get the OnMessageReceived event properly after I subscribe a topic, kill the app, send the message through Firebase console and click on the notification.

  • Built with Unity 2020.3.18f1
  • FCM Unity testapp
  • Firebase Unity SDK 8.1.0
  • Built Android apk and deployed to a physical Pixel device (my phone 😒)

Here is what I did after the app was deployed:

  1. Launched the app for the first time.
  2. Picked a topic and click on Subscribe button.
  3. Send a message from Firebase console and confirm the message is received when the app is in the foreground.
  4. Killed the app.
  5. Sent another message from Firebase console. Confirmed the notification is received on the device.
  6. Clicked on the notification, confirmed the message is received in Unity app.

Here is a screenshot of the app for the second launch. Screenshot_20210914-185520

I would be great if you can help us to diagnose the issue with the following steps.

  1. Try to run the steps I described above and see if you reproduce the issue using FCM quickstart,
  2. Either with the quickstart or your app, try to see if there is any abnormal logs using adb logcat when the issue occurs.
  3. This issue #1088 sometimes can prevent the async FCM APIs from finishing with some configurations. This only occurs from 8.0.0. Could you try to downgrade to 7.2.0 and see if the issue still occurs? Or FWIW, upgrade to 8.2.0 and see if anything changed. You should find all the .unitypackage you need from this page (FCM, Crashlytics and Analytics)

Appreciate it. Shawn