firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
819 stars 424 forks source link

messaging/testapp not working #1367

Open nmtoan91 opened 5 months ago

nmtoan91 commented 5 months ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Problem: The app can receive the message as I see the log in the demo UI but there is no notification shown on my phone. I followed the steps correctly in the messaging/testapp. I even enable the notification permission manually for the app.

google-oss-bot commented 5 months ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

Parth10277 commented 4 months ago

The same issue occurred with the newly created project,

I had just imported the .unitypackage of Cloud Messaging, and it's stopped creating builds.

argzdev commented 1 month ago

Hey nmtoan91. From your description, it seems to me that the app is receiving the notification message in the logs when your phone is on the foreground. This is an intended behavior. Keep in mind that the behavior of the Firebase messages differentiate when the app is in background or foreground. In our documentations:

  1. 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.
  2. When in the foreground, your app receives a message object with both payloads available.

If you notice in #2, the app will likely receive a message object but will not a notification pop up. If you'd like to receive a notification even if the app is on the foreground, you'll have to add your code logic to display notifications in the OnMessageReceived event. You may check out the documentations how to get started here.