-2

I am in a situation , where my webservice sends me notification which includes

{
    "apiKey": "xxxxx-xxx-xxx-xxxx-xxxxxxx",
    "appKey": "xxxxx-xxx-xxx-xxxx-xxxxxxx",
    "sendAll": true,
    "content": {
        "subject": "Test Lottery",
        "message": "Notification Msg",
        "action": {
            "type": "DEFAULT",
            "data": "url|intent|...",
            "labe": "label"
        },
        "payload": "{'uid':'1','type':'LD'}",
        "sound": "default.caf",
        "badge": "+1"
    }
}

On click of the notification which appeared on top , I need to get the uid and type

I am using Xtify for push notification.....

karthik
  • 29
  • 1
  • 7
  • `I am having a beginner knowledge in JSON` then you have to extend the knowledge ... – Selvin Sep 23 '14 at 09:08
  • leave those funny comments ..... if possible help me ... – karthik Sep 23 '14 at 09:13
  • 1
    seems like it is not possible(to help you) becuase you are too lazy to use http://google.com before asking the question, it is duplicate of many questions here ... please do some research before asking – Selvin Sep 23 '14 at 09:14
  • selvin please allow other to help .... – karthik Sep 23 '14 at 09:18
  • @karthik : its not a way to ask help.......... you are here to help.. if you talk like that no one gonna help you.... – Pragnesh Ghoda シ Sep 23 '14 at 09:18
  • @karthik : be polite... at-least when you are asking for help... – Pragnesh Ghoda シ Sep 23 '14 at 09:18
  • @Selvin Is right . Such kind of questions are not allowed here as there are so many questions asked like this. You need to put your efforts to find out solutions atleast besides directly getting prepared materials. And its so simple question. – GrIsHu Sep 23 '14 at 09:21

1 Answers1

0

Try This..

String JSON ="YOUR JSON RESULT STRING";
try {
    JSONObject jsonresult = new JSONObject(JSON);

    String apiKey= jsonresult.getString("apiKey");
    String appKey= jsonresult.getString("appKey");
    boolean sendAll= jsonresult.getBoolean("sendAll");

    JSONObject contentObject = jsonresult.getJSONObject("content");
    String subject= jsonresult.getString("subject");
    String message= jsonresult.getString("message");
    String sound= jsonresult.getString("sound");
    String badge= jsonresult.getString("badge");

    JSONObject actionObject = jsonresult.getJSONObject("action");

    String type= jsonresult.getString("type");
    String data= jsonresult.getString("data");
    String labe= jsonresult.getString("labe");

    JSONObject payloadObject = jsonresult.getJSONObject("payload");
    // do your code..

    }
} catch (JSONException e) {
    e.printStackTrace();
    //catching exceptions if any...
}
Pragnesh Ghoda シ
  • 8,318
  • 3
  • 25
  • 40