From 55a38bf4fa15a5e477f00560d3857a5953e8c896 Mon Sep 17 00:00:00 2001 From: mueller-ma Date: Mon, 5 Aug 2024 21:13:05 +0200 Subject: [PATCH] Fix notifications without message I personally use only the title for most notifications, so I discovered a crash when using the following code to create a notification: ```js actions.notificationBuilder() .withTitle("foo") .send(); ``` There's no message passed to `notificationBuilder()`. In this case, handle it like an empty string as message. Signed-off-by: mueller-ma --- .../main/java/org/openhab/habdroid/model/CloudNotification.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/main/java/org/openhab/habdroid/model/CloudNotification.kt b/mobile/src/main/java/org/openhab/habdroid/model/CloudNotification.kt index 825e28b053..646aaa3b2f 100644 --- a/mobile/src/main/java/org/openhab/habdroid/model/CloudNotification.kt +++ b/mobile/src/main/java/org/openhab/habdroid/model/CloudNotification.kt @@ -133,7 +133,7 @@ fun JSONObject.toCloudMessage(): CloudMessage? { CloudMessage.CloudNotification( id = id, title = payload?.optString("title").orEmpty(), - message = payload?.getString("message") ?: getString("message"), + message = payload?.optString("message", "") ?: getString("message"), createdTimestamp = created, icon = (payload?.optStringOrNull("icon") ?: optStringOrNull("icon")).toIconResource(), tag = tag,