From ac7c3bbdaae85a9685e491090abda115222fa34b Mon Sep 17 00:00:00 2001 From: koalasat Date: Wed, 21 Aug 2024 10:14:57 +0200 Subject: [PATCH] Skip notification if title empty --- .../main/java/com/robosats/NotificationsService.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mobile/android/app/src/main/java/com/robosats/NotificationsService.java b/mobile/android/app/src/main/java/com/robosats/NotificationsService.java index a105966f..59046d18 100644 --- a/mobile/android/app/src/main/java/com/robosats/NotificationsService.java +++ b/mobile/android/app/src/main/java/com/robosats/NotificationsService.java @@ -205,11 +205,16 @@ public class NotificationsService extends Service { }); try { JSONArray results = new JSONArray(body); - if (results.length() > 0) { - JSONObject notification = results.getJSONObject(0); + for (int i=0; i < results.length(); i++) { + JSONObject notification = results.getJSONObject(i); 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; try { @@ -223,6 +228,7 @@ public class NotificationsService extends Service { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putLong(token, milliseconds); editor.apply(); + break; } } catch (JSONException e) { throw new RuntimeException(e);