0

I'm using Amazon SNS to send push notifications to an Android device. If I send the following JSON I can't read the parameters in the data element.

{ "default": "message here", "GCM": { "data": { "message": "This is the message" } } }

I can read the default element but in my broadcastreceiver I can't do this.

protected void onHandleIntent(Intent intent) {

    Bundle extras = intent.getExtras();

    Log.d("GCM",extras.getString("message");

}

Trying to read the message element causes an error.

If I send directly through GCM I can read all of the parameters that start with data. using the above method with no problem at all.

What am I doing wrong?

Xmlwiz
  • 31
  • 2
  • Dump the contents. See http://stackoverflow.com/questions/5968896/listing-all-extras-of-an-intent. – jarmod Feb 26 '15 at 15:41
  • Received: Bundle[{from=xxxxxxxxxxxx, default=message here, android.support.content.wakelockid=1, collapse_key=do_not_collapse}] – Xmlwiz Mar 03 '15 at 13:14

1 Answers1

1

You need escape double quotation in GCM value.

{ "default": "message here", "GCM": "{ \"data\": { \"message\": \"This is the message\" } }" }
endo
  • 19
  • 5