As per firebace doc, we can send FCM data messages in below format:
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMEFQ3P1...",
"data":{
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
}
}
}
But, I am required to send data as JSON Array like below:
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoIZvvDMExUdFQ3P1...",
"data":{
"geofence":[{
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
{
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
}]
}
}
}
I am getting below error if I try to send JSON Array in request body for sending messages:
Unable to send message to Firebase:
{ "error":
{ "code": 400,
"message": "Invalid value at 'message.data[0].value' (Map), Cannot have repeated items ('geofence') within a map.\nInvalid JSON payload received. Unknown name \"\" at 'message.data[0].value': Proto fields must have a name.",
"status": "INVALID_ARGUMENT",
"details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "message.data[0].value", "description": "Invalid value at 'message.data[0].value' (Map), Cannot have repeated items ('geofence') within a map." }, { "field": "message.data[0].value", "description": "Invalid JSON payload received. Unknown name \"\" at 'message.data[0].value': Proto fields must have a name." } ] } ]
}}
Android code is expecting data in JSON Array format not in String. I am stucked here badly.
Any help will be highly appreciated.