I am using GCM to push notification to mobile using this example and the notification is pushed. But I could not able to parse the bundle received  from intent.
This is the bundle I got from log Bundle[{message={"valid":"bbb","deal":"its working","address":"some","name":"aaa"}, android.support.content.wakelockid=1, collapse_key=do_not_collapse, from=198162727742}]
.
and I converted it into string and then tried to convert to json object using this codejson = new JSONObject(message); but no luck. can anybody tell what I am doing wrong here. thanks in advance
In the method that received the intent do this:
protected void onMessage(Context context, Intent intent) {
    //log the message in JSON format
    Log.i(TAG, "Received message >> " + intent.getExtras().toString());
    //Retrieve message and extra
    String message = intent.getExtras().getString("message");
}
                        The real JSON Object is this:
{"valid":"bbb","deal":"its working","address":"some","name":"aaa"}
The rest is not actually JSON.
Try to parse just this line, and it will work =)
So:
json = new JSONObject( bundle.getString("message") );
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With