我需要有关android中fcm推送问题的帮助。 当我收到手机上的推送时,我无法在我放入FirebaseMessagingService的日志中收到它。
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "FROM:" + remoteMessage.getFrom());
Log.e(TAG, "FROM:");
if (remoteMessage == null)
return;
//Check if the message contains data
// 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());
}
}
//Check if the message contains notification
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Mesage body:" + remoteMessage.getNotification().getBody());
sendNotification(remoteMessage.getNotification().getBody());
}
}