Hi im working with postman to make my json object FCM message: But when i try to send:
{
"to":"fzvihT7dFUI:APA91bFVhnWAxXVjlWiiHIs9ZUyL1DE2hZO6GpItJtReh3hcKF1kD6mLuQq9fNP9xvS5bOFWUOG-OW-uyOedc1C43m8jfvD4OOfsBYuMbM7t1-dZEy2kQcuv3gJw6dhneVus2AR_hQHQ",
"data":[
{
"time":1501385514224,
"CC":"1030626890"
}
],
"notification":{
"body":"SPO2:95 \nPulso:75",
"title":"El paciente Daniel Ortiz nesecita asistencia"
}
}
The response its:
Field "data" must be a JSON array: [{"CC":"1030626890","time":1501385514224}]
But i know the [{"CC":"1030626890","time":1501385514224}]
its a array, i dont understand the problem.
What i made wrong?
From the Firebase Cloud Messaging documentation, it seems like data
should be a JSON object:
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
}
I'm not sure why the error message talks says it needs to be an array. It's like meant as an "associative array" which is really just another term for a JSON object.
I might be too late but for those who still face this problem , following change saved me.
By adding JSON_FORCE_OBJECT
to json_encode()
it will add missing braces so it should be something like this:
json_encode($fields ,JSON_FORCE_OBJECT));
That's it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With