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
질문됨 3달 전173회 조회
1개 답변
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
답변함 3달 전
profile picture
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠