look to the notificationhow to get Message text from this Firebase Cloud Messaging unity C# this is my code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pushfirebase : MonoBehaviour {
public void Start() {
Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
}
public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) {
UnityEngine.Debug.Log("Received Registration Token: " + token.Token);
}
public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) {
UnityEngine.Debug.Log("Received a new message from: " + e.Message.From);}
}
In your OnMessageReceived
method, you can access the message body like so:
e.Message.Notification.Body
You may need to be a little bit careful though because the Notification
object won't always be present. So check to make sure it isn't null
before you use it.