Android/Firebase - Error while parsing timestamp in GCM event - Null timestamp

前端 未结 8 2168
自闭症患者
自闭症患者 2020-11-28 14:38

I\'m building an Android app which will receive push notifications. I\'ve got Firebase Cloud Messaging setup and pretty much working, such that I can send the following payl

8条回答
  •  醉酒成梦
    2020-11-28 14:59

    replace

     "notification" : {
        "title" : "title !",
        "body" : "body !",
        "sound" : "default"
      },
      "condition" : "'xxx' in topics",
      "priority" : "high",
      "data" : {
    ....
    

    by (remove notification) :

    {
      "condition" : "'xxxx' in topics",
      "priority" : "high",
      "data" : {
        "title" : "title ! ",
         "body" : "BODY",
     ......
    }
    

    And on you code : Replace :

     @Override
            public void onMessageReceived(RemoteMessage remoteMessage) { 
               remoteMessage.getNotification().getTitle();
               remoteMessage.getNotification().getBody();
    
            }
    

    by

    @Override
        public void onMessageReceived(RemoteMessage remoteMessage) { 
           remoteMessage.getData().get("title");
           remoteMessage.getData().get("body");
    
        }
    

提交回复
热议问题