Skip notification if title empty

This commit is contained in:
koalasat 2024-08-21 10:14:57 +02:00
parent e9863417dd
commit ac7c3bbdaa
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157

View File

@ -205,11 +205,16 @@ public class NotificationsService extends Service {
}); });
try { try {
JSONArray results = new JSONArray(body); JSONArray results = new JSONArray(body);
if (results.length() > 0) { for (int i=0; i < results.length(); i++) {
JSONObject notification = results.getJSONObject(0); JSONObject notification = results.getJSONObject(i);
Integer order_id = notification.getInt("order_id"); Integer order_id = notification.getInt("order_id");
String title = notification.getString("title");
displayOrderNotification(order_id, notification.getString("title"), coordinator); if (title.isEmpty()) {
continue;
}
displayOrderNotification(order_id, title, coordinator);
long milliseconds; long milliseconds;
try { try {
@ -223,6 +228,7 @@ public class NotificationsService extends Service {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putLong(token, milliseconds); editor.putLong(token, milliseconds);
editor.apply(); editor.apply();
break;
} }
} catch (JSONException e) { } catch (JSONException e) {
throw new RuntimeException(e); throw new RuntimeException(e);