0
我试图使用分析推送向我自己的设备发送推送通知。但是,每当我尝试将JSONObject设置为数据时,我的设备将不会收到任何内容。我试过setMessage(),它的工作原理。任何想法有什么不对?无法使用分析推送发送数据
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("username", "[email protected]");
ParsePush push = new ParsePush();
JSONObject obj= null;
try {
obj = new JSONObject("{\"channel\":\"[email protected]\",\"cat\":\"WP\"}");
obj.put("action","com.parse.starter.UPDATE_STATUS");
} catch (JSONException e) {
e.printStackTrace();
}
push.setQuery(pushQuery);
push.setData(obj);
push.sendInBackground();
}
而对于接收机
@Override
public void onPushOpen(Context context, Intent intent) {
Bundle extras = intent.getExtras();
String jsonData = extras.getString("com.parse.Data");
JSONObject jsonObject;
try {
jsonObject = new JSONObject(intent.getExtras().getString("com.parse.Data"));
String channel = jsonObject.getString("channel");
Log.d("Channel", channel);
} catch (JSONException e) {
e.printStackTrace();
}
Intent i = new Intent(context, Activity_Invite_nom.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
是你的接收机方法触发与否? –
@kishorejethava如果我没有收到任何通知,我不能触发它 –
您可以从Parse Data浏览器(GUI)中看到notif状态点击'Push'选项卡,您可以看到列表及其状态 –