title: Amazon SNS GCM/FCM message payload
body: <p>I am trying to send a push notification (PN) from my application server to an android device using publish end point in the Amazon SNS console with this message and message structure as json it works fine. </p>
  
  <pre><code>{
  "GCM": "{ \"notification\": { \"text\": \"test message\" } }"
  }
  </code></pre>
  
  <p>But when I try to implement the same in Java it the device does not receive the notification.</p>
  
  <pre><code>PublishRequest publishRequest = new PublishRequest();
          publishRequest.setTargetArn("arn:aws:sns:ap-south-1:818862955266:endpoint/GCM/TestApp/a1ec8114-58c9-371b-bb76-d8d16e674e52");
          String message = "{\"GCM\": \"{ \"notification\": { \"text\": \"test message\" } }\"}";
  
          ObjectMapper mapper = new ObjectMapper();
          PushRequest pushRequest = new PushRequest();
          pushRequest.setDef("Test");
  
          GCM gcm = new GCM();
          Notification notification = new Notification();
          notification.setText("hello");
          gcm.setNotification(notification);
          pushRequest.setGcm(gcm);
  
          String jsonInString = mapper.writeValueAsString(pushRequest);
          publishRequest.setMessage(jsonInString);
          publishRequest.setMessageStructure("json");
          System.out.println("Publist request:"+publishRequest.toString());
          PublishResult publishResult = amazonSNSTemplate.getAmazonSNSClient().publish(publishRequest);
          System.out.println(publishResult.toString());
          System.out.println(publishResult.getSdkResponseMetadata().toString());
  
  
  public class PushRequest {
  
      @JsonProperty("default")
      private String def;
      @JsonProperty("GCM")
      private GCM gcm;
      public String getDef() {
          return def;
      }
      public void setDef(String def) {
          this.def = def;
      }
      public GCM getGcm() {
          return gcm;
      }
      public void setGcm(GCM gcm) {
          this.gcm = gcm;
      }
  
  
  
  }
  
  public class GCM {
      private Notification notification;
  
      @JsonProperty("notification")
      public Notification getNotification() {
          return notification;
      }
  
      public void setNotification(Notification notification) {
          this.notification = notification;
      }
  
  
  }
  public class Notification {
      private String text;
  
      @JsonProperty("text")
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
  }
  </code></pre>
  
  <p>Response on the console</p>
  
  <blockquote>
    <p>Publist request:{TargetArn:
    arn:aws:sns:ap-south-1:818862955266:endpoint/GCM/TestApp/a1ec8114-58c9-371b-bb76-d8d16e674e52,Message:
    {"default":"Test","GCM":{"notification":{"text":"hello"}}},MessageStructure:
    json,MessageAttributes: {}} {MessageId:
    7dfb613c-06d0-5fe6-8766-3068c9438614}
    {AWS_REQUEST_ID=3d0e13f4-b2be-5c95-ad43-42a07d2d5567}</p>
  </blockquote>
  
  <p>What could be the problem?</p>
  
  <p>Also, I am following the pattern suggested in the SO answer <a href="https://stackoverflow.com/questions/18845984/how-to-send-extra-parameters-in-payload-via-amazon-sns-push-notification">here</a>.</p>