Karthi Keyan
Karthi Keyan

Reputation: 147

Firebase Push Notification is Not Received when App is in Foreground

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?

Upvotes: 1

Views: 1700

Answers (1)

acoolaum
acoolaum

Reputation: 2132

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
  }
}

Upvotes: 1

Related Questions