facebook twitter hatena line email

「Unity/Firebase/CloudMessaging」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「==DL&Import== FirebaseMessaging.unitypackage」)
 
(サンプル)
 
(同じ利用者による、間の1版が非表示)
行1: 行1:
 
==DL&Import==
 
==DL&Import==
 
FirebaseMessaging.unitypackage
 
FirebaseMessaging.unitypackage
 +
 +
==サンプル==
 +
<pre>
 +
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);
 +
}
 +
</pre>
 +
 +
ログ
 +
<pre>
 +
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
 +
</pre>
 +
 +
==参考==
 +
公式fcm
 +
https://firebase.google.com/docs/cloud-messaging/unity/client?hl=ja

2019年6月1日 (土) 23:55時点における最新版

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