FCM Data payload received in android not in json format

后端 未结 1 1241
误落风尘
误落风尘 2020-12-19 03:32

I am getting the data payload from the firebase not in json format, instead I am getting custom key-value pairs as following format:

Data Payload:{image=htt         


        
相关标签:
1条回答
  • 2020-12-19 04:12

    I am getting the data payload from the firebase not in json format

    Yes, Its behaving as intended.

    Because Data payload contains custom key-value pairs not a JSON format

    I have to parse the data using Json parsing for further processing.

    You need to use Map<String, String> to convert data payload in to a JSONObject

    check below example

    SAMPLE CODE

    Map<String, String> params = remoteMessage.getData();
    JSONObject object = new JSONObject(params);
    Log.e("JSON_OBJECT", object.toString());
    
    0 讨论(0)
提交回复
热议问题