Skip to content

Commit

Permalink
Fix notifications without message (openhab#3794)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mueller-ma authored Aug 7, 2024
1 parent 85ee2c0 commit 4868e79
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4868e79

Please sign in to comment.