Error sending FCM message

2,942 views
Skip to first unread message

Ori Idan

unread,
Jun 22, 2023, 8:26:15 AM6/22/23
to Firebase Google Group
Hello,

I am trying to use the new API for FCM (the legacy API works fine now).
I get the following error:
Invalid JSON payload received. Unknown name \"to\": Cannot find field.\nInvalid JSON payload received. Unknown name \"data\": Cannot find field.

The JSON payload is:
{"to":"1234","data":{"message":"This is an FCM notification message!"}}

Where 1234 is replaced with the actual registration id.

Ori Idan

Jen Harvey Hugg

unread,
Jun 22, 2023, 10:20:18 AM6/22/23
to fireba...@googlegroups.com
Hi, Ori:

The payload format is a little different in the v1 API, check out the new format here:


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/b4e6b7a3-93b5-4a6f-b125-799d23186a1en%40googlegroups.com.

Ori Idan

unread,
Jun 22, 2023, 3:37:52 PM6/22/23
to Firebase Google Group
Thank you for your answer.
I see that the registration number of my client is given in the token field so for simple notifications I don't need to to and data field.

How do I send the same message to several registration numbers (I want to send the message to all devices owned by same user) do I have to send in a loop or is there a better method?
Also my current payload includes the following fields: message, title, type (number used by my app), param (url in case of a notification containing url) how can I sent this data?

Reply all
Reply to author
Forward
0 new messages