嗨,我正在尝试从Android的Firebase通知中获取数据。
我正在使用nodejs Firebase Admin SDK,但在AVD上收到通知,但在logcat中没有任何数据,该如何解决?
从PHP和logcat发送以显示Firebase的键/值可以很好地工作。
我在日志中唯一得到的是:
09-15 21:01:36.363 13147-18088/com.ok.myapp V/FA: Connecting to remote service
09-15 21:01:36.372 13147-18088/com.ok.myapp D/FA: Connected to remote service
09-15 21:01:36.373 13147-18088/com.ok.myapp V/FA: Processing queued up service tasks: 1
09-15 21:01:41.443 13147-18088/com.ok.myapp V/FA: Inactivity, disconnecting from the service
MyFirebaseMessangerService.java
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
Log.d(TAG, "key, " + key + " value " + value);
}
Log.e(TAG, "From: " + remoteMessage.getFrom());
if (remoteMessage == null)
return;
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
handleNotification(remoteMessage.getNotification().getBody());
}
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
try {
JSONObject json = new JSONObject(remoteMessage.getData().toString());
handleDataMessage(json);
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
}
}