Closed BarakChamo closed 7 years ago
Did you try the instructions in plugin.xml to allow notifications when the app is closed?
I fixed this problem with some help on SO.
The problem, as described in the thread, is that Parse uses a different data structure for their Push service and assigns the message
to the alert
key with different handlers assigned to handle notifications. What I ended up doing is cloning PushPlugin and editing the problematic lines in place:
if (extras != null) {
/*
Original Interceptor
*/
// // if we are in the foreground, just surface the payload, else post it to the statusbar
// if (PushPlugin.isInForeground()) {
// extras.putBoolean("foreground", true);
// PushPlugin.sendExtras(extras);
// } else {
// extras.putBoolean("foreground", false);
// // Send a notification if there is a message
// if (extras.getString("message") != null && extras.getString("message").length() != 0) {
// createNotification(context, extras);
// }
// }
/*
Parse Fix
*/
if (PushPlugin.isInForeground()) {
extras.putBoolean("foreground", true);
PushPlugin.sendExtras(extras);
} else if (extras.getString("message") != null && !extras.getString("message").isEmpty()) {
extras.putBoolean("foreground", false);
createNotification(context, extras);
} else {
try{
JSONObject data = new JSONObject(extras.getString("data"));
// JSONObject data = payload.getJSONObject("data");
String message = data.getString("alert"); //parse puts the message as an alert if you don't use custom json payload
extras.putString("message", message);
createNotification(context, extras);
}
catch (JSONException e)
{
Log.d(TAG, "Notification JSON Prase Error");
}
}
}
Hi there,
After installing the plugin incoming android notifications are captured but the app immediately crashes with the following error:
Anyone came across this error loading the receiver?