Skip to content

Instantly share code, notes, and snippets.

@fuka
Last active August 5, 2017 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuka/10f05b9cfb1c038c3d9be1535d9a5b10 to your computer and use it in GitHub Desktop.
Save fuka/10f05b9cfb1c038c3d9be1535d9a5b10 to your computer and use it in GitHub Desktop.
Firebase Cloud Messagingの中身をログに出力する
...
<receiver
android:name=".FirebaseDataReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</receiver>
...
package com.example.firebase;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
public class FirebaseDataReceiver extends WakefulBroadcastReceiver {
private final String TAG = FirebaseDataReceiver.class.getName();
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
String valueString = (value != null) ? value.toString() : "<NULL>";
Log.d(TAG, "KEY: " + key + ", VALUE: " + valueString);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment