Skip to content

Commit

Permalink
Fix parsing of on-click
Browse files Browse the repository at this point in the history
on-click has no label, so it needs special parsing.

Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma committed Jul 10, 2024
1 parent f16d7f5 commit 3585fa6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import kotlinx.coroutines.runBlocking
import org.openhab.habdroid.model.CloudNotification
import org.openhab.habdroid.model.CloudNotificationAction
import org.openhab.habdroid.model.CloudNotificationId
import org.openhab.habdroid.model.toCloudNotificationAction
import org.openhab.habdroid.model.toOH2IconResource
Expand Down Expand Up @@ -61,7 +62,7 @@ class FcmMessageListenerService : FirebaseMessagingService() {
icon = data["icon"].toOH2IconResource(),
tag = data["tag"],
actions = actions,
onClickAction = data["on-click"].toCloudNotificationAction(),
onClickAction = data["on-click"]?.let { CloudNotificationAction("", it) },
mediaAttachmentUrl = data["media-attachment-url"]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class NotificationHandlingReceiver : BroadcastReceiver() {
BackgroundTasksManager.enqueueNotificationAction(context, action)
is CloudNotificationAction.Action.UrlAction ->
action.url.toUri().openInBrowser(context)
is CloudNotificationAction.Action.NoAction -> {
// no-op
}
else -> {
throw IllegalArgumentException("Got unexpected action: $action")
}
Expand Down

0 comments on commit 3585fa6

Please sign in to comment.