我在这里发送推送:
ParsePush parsePush = new ParsePush();
ParseQuery parseQuery = ParseInstallation.getQuery();
parseQuery.whereEqualTo("UserId", userId);
JSONObject data = new JSONObject();
try {
data.put("Name", objects.get(0).fetchIfNeeded().get("Name").toString());
data.put("Amount", arr.get(ii + 1));
data.put("Date", arr.get(ii+2));
data.put("Time", arr.get(ii+3));
data.put("Location", objects.get(0).fetchIfNeeded().get("Address").toString());
parsePush.setData(data);
}
catch (Exception ex) {
}
parsePush.sendMessageInBackground("blah blah blah", parseQuery);
当我尝试在onPushOpen
收到它时,我找不到数据,当我转到JSON时我得到了异常。
public class ParsePushReceiver extends ParsePushBroadcastReceiver{
@Override
public void onPushOpen(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
if (intent != null) {
try {
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
String name = json.getString("Name");
String amount = json.getString("Amount");
String date = json.getString("Date");
String time = json.getString("Time");
String location = json.getString("Location");
i.putExtra("Name", name);
i.putExtra("Amount", amount);
i.putExtra("Date", date);
i.putExtra("Time", time);
i.putExtra("Location", location);
context.startActivity(i);
} catch (Exception ex) {
}
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
以下是例外:
java.lang.NullPointerException:尝试在空对象引用上调用接口方法'java.lang.Object [] java.util.Collection.toArray()'
我认为清单是好的,不是问题,因为接收器正在工作,除了数据问题。