-2

我处于一种情况,我的网络服务向我发送通知,其中包括

{
    "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"
    }
}

单击顶部出现的通知时,我需要获取uidtype

我正在使用 Xtify 进行推送通知.....

4

1 回答 1

0

试试这个..

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...
}
于 2014-09-23T09:15:16.660 回答