1
votes

I am using unity 2018 with Firebase. I am working on Firebase Push Notification.The Push Notification Message is Received well.

But when my run my app running in foreground the push notification message is not received. But when my close my app. The push notification message is received.

What i have to do for Receiving Push Notification when my app is in Foreground?

1
A quick Google search led me to this link indicating the following : When the app is in foreground, the received messages are processed by the app, and since there’s no logic to handle it, nothing will happen! Meaning you have to handle it. The notification won't appear in the notification center. - Hellium

1 Answers

1
votes

You have to handle push notification manually in callback:

//Subscribe on application start
public void Start() {
  Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
}

public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) 
{
  UnityEngine.Debug.Log("Received a new message from: " + e.Message.From);
  if (e.Message.NotificationOpened == false)
  {
     // Show PopUp or Do something here
  }
}