public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService{
String TAG = "FirebaseMessagingService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage){
Log.i(TAG," input string :"+ String.valueOf(remoteMessage.getData()));
/**
* Parse remote input and pass id, action, frequency and payload to eventHandler.
* **/
String messageType = remoteMessage.getMessageType();// messageType is null always
if(messageType.equalsIgnoreCase("Data")){
Log.i(TAG, " Data notification received");
}
else if(messageType.equalsIgnoreCase("Notification")){
Log.i(TAG, " Push notification received");
}
}
最佳答案
我不确定 getMessageType()
应该返回什么。但它似乎不太可能返回 Data
或 Notification
,因为 a single message can contain both notification and data information .
关于android - remoteMessage.getMessageType 在 onMessageReceived 中返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38405281/