using System.Collections;
using System.Collections.Generic;
using Firebase;
using Firebase.Analytics;
using UnityEngine;

public class FirebaseStart : MonoBehaviour
{
    private FirebaseApp app;
    private string myToken;

    public string MyToken { get => myToken; set => myToken = value; }

    // Start is called before the first frame update
    void Start()
    {
        Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
        Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
    }

    public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) {
        if (!token.Token.Equals("")) {
            MyToken = token.Token;
            Debug.Log("Setting token to " + MyToken );
        }
        Debug.Log("Received Registration token: " + token.Token);
    }

    public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) {
        Debug.Log("Received New message from: " + e.Message.From);

}
}
