我处于这种情况,我的网络服务向我发送包含
的通知{
"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"
}
}
点击顶部显示的通知,我需要获取uid
和type
我正在使用Xtify进行推送通知.....
答案 0 :(得分: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...
}