facebook twitter hatena line email

Unity/Firebase/CloudMessaging

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

DL&Import

FirebaseMessaging.unitypackage

サンプル

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

ログ

06-01 22:00:08.251 19819 19848 I Unity   : Received Registration Token: fOY-0EKDOek:APA91bHHG7ims40sPYvy00G7Ux-XArVXVV8OeQyC4tf-401K4S_oP3dYEd1ix_bZtwrkc6gmk-dw0M42_7TnHoNb3G8ll9GHRXIwhsKbnLC63v4jaA7cRC-FcKxxxxxxxxxxxxxxxx
06-01 21:58:32.858 18399 18432 I Unity   : Received a new message from: 175245285827

参考

公式fcm https://firebase.google.com/docs/cloud-messaging/unity/client?hl=ja