Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)

I want to send mobile push notifications to GCM via AWS SNS. And as per the documentation, one may include either a "notification" payload or a "data" payload. And if we send a notification payload, then GCM will take care of showing the notification on the end-user device for you.

Using AWS SNS Console, I tried sending a notification-only payload but got the below error:

Invalid parameter: Message Reason: Invalid notification for protocol GCM: data key is expected in the json message (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter)

I'm sending:

{

  "GCM":"{\"notification\":{\"title\":\"Test Message\"}}"

}

Can anyone help me out?

1 Answer

0 votes
by (12.4k points)

SNS currently does not currently support GCM's "notification" payload type as per their documentation. SNS supports "data" payload type only. So until SNS supports GCM notification payload, you have to handle the display of notifications yourself by extending the class "GcmListenerService" and overriding the method "onMessageReceived".

Do you want to learn more about AWS? Checkout AWS Training by Intellipaat!

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Nov 29, 2020 in AWS by devin (5.6k points)
0 votes
1 answer
asked Nov 21, 2020 in AWS by devin (5.6k points)

Browse Categories

...