SRahmani
SRahmani

Reputation: 1

unity-firebase cloud messaging issue

I have developed a game with unity and I have used 'Firebase Cloud Messaging' for push notification. I have one problem. when I clear the received notification in tray, it seems like the message related to it is also deleted. so 'MessageReceived' is not called when I open the app.

  1. I experienced this problem on android. Haven't tested it on ios yet.
  2. I use firebase admin sdk for sending messages.(written with node js)

is there a way to clear notification tray without deleting the message? thanks for any help in advance

Upvotes: 0

Views: 1513

Answers (1)

Thomas Maw
Thomas Maw

Reputation: 423

There is some extra setup required to route notifications when the app is not running on Android.

See the Firebase docs for more information

Quote from documentation:

When the app is not running at all and a user taps on a notification, the message is not, by default, routed through FCM's built in callbacks. In this case, message payloads are received through an Intent used to start the application.

Messages received while the app is in the background have the content of their notification field used to populate the system tray notification, but that notification content will not be communicated to FCM. That is, FirebaseMessage.Notification will be a null.

Basically you need to use the custom launch activity bundled with Firebase Messaging instead of the default UnityPlayerActivity. This activity is called MessagingUnityPlayerActivity can can be found inside libmessaging_unity_player_activity.jar. You'll need to create a AndroidManifest.xml file to instruct the app to use this custom activity instead of the default Unity one.

Upvotes: 1

Related Questions