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
posta 3 mesi fa173 visualizzazioni
1 Risposta
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
con risposta 3 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande