AWS SNS with FCM: Notification body is invalid

0

I'm unable to send a test SNS using FCM. I have setup my platform application to use FCM and a token. I get the following error message when I attempt to send a test message to one of my endpoints using the console:

{"DeliveryAttempts":1,","EventType":"DeliveryFailure","FailureMessage":"Notification body is invalid","FailureType":"InvalidNotification","Service":"SNS","Time":"2024-03-07T18:59:46.489Z"}

I attempted the following message types:

  • Just raw text
  • JSON:

{ "GCM": "{ "data": { "message": "Sample message for Android endpoints" } }" }

and

{ "GCM":"{ "notification": { "body": "Sample message for Android or iOS endpoints", "title":"TitleTest" } }" }

None of these appear to work. What is the correct way to format the body for FCM?

Sending a test message to my phone from Firebase is working.

fnllc
feita há 3 meses173 visualizações
1 Resposta
0

The error message "Notification body is invalid" typically occurs when the payload you're sending is not properly formatted according to the Firebase Cloud Messaging (FCM) protocol.

Here's the correct format for sending a notification to FCM via AWS SNS:

{
  "GCM": "{\"notification\":{\"body\":\"This is a notification message for FCM!\",\"title\":\"FCM Message\"}}"
}

If you want to send data payload instead of a notification, you can use the following format:

{
  "GCM": "{\"data\":{\"message\":\"This is a data message for FCM!\"}}"
}

Test the setup

  1. Go to SNS console and open the platform application.
  2. Select the endpoint and choose “Publish message”.
  3. Select “Custom payload for each delivery protocol” and add the above message body.
AWS
respondido há 3 meses
profile picture
ESPECIALISTA
avaliado há 2 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas