应用运行时如何从Firebase接收通知?

时间:2018-10-23 20:34:29

标签: firebase unity3d firebase-cloud-messaging

我正在尝试从Firebase调用通知,并且设法在关闭应用程序或在后台运行时获取通知,但是问题是我在应用程序内部时从未收到通知,我该如何配置Firebase以便我还可以在应用运行时发出通知?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FireBaseNotificationController : MonoBehaviour {

public string valueTokeniD;

// Use this for initialization
void Start()
{       
    Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;       
    Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;        
}

public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token)
{
    valueTokeniD = token.Token;
    Debug.Log("onToken ID:" + token.Token);
    UnityEngine.Debug.Log("Received Registration Token: " + token.Token);
}

public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e)
{        
    UnityEngine.Debug.Log("From: " + e.Message.From);
    UnityEngine.Debug.Log("Message ID: " + e.Message.MessageId);        
}

}

0 个答案:

没有答案