Files
Ryan Warner 9779d0576a Fix Live Activity ContentState decoding and Direct push delegate (#4677)
## Summary

Follow-up fixes to two issues surfaced while testing #4671 end-to-end.

1. **`HALiveActivityAttributes.ContentState.countdownEnd` decoded via
Unix epoch.** ActivityKit decodes the `content-state` JSON arriving via
APNs with the default `JSONDecoder`, whose `Date` strategy is
`.deferredToDate` (seconds since the 2001 reference date). HA core sends
`countdown_end` as Unix epoch seconds, matching the documented
`data.when` / `data.when_relative` user contract and the in-app handler
that already does `Date(timeIntervalSince1970:)`. Without a manual
decode the APNs push path renders countdowns ~31 years in the future.
Adds explicit `init(from:)` and `encode(to:)` that map `countdownEnd`
via `timeIntervalSince1970`. All other fields use
`container.decodeIfPresent` so behavior is unchanged for them.

2. **`NotificationManagerLocalPushInterfaceDirect` assigns
`LocalPushManager.delegate`.** The Extension path assigns the delegate
at line 197; the Direct path (used on simulator and Mac Catalyst) never
did. On those platforms that meant silent commands such as
`clear_notification` (no alert title/body) were dropped: iOS doesn't
fire `willPresent` for content-less notifications, and the delegate is
the only fallback that routes into `commandManager`. One-line fix that
brings the Direct factory into line with the Extension's behavior.

Real-device verification (iPhone 13 Mini, iOS 26.5, paid Developer
account): chronometer countdown rendered correctly 60→0 with the Codable
fix in place. Without it the timer rendered as if `Date` were
seconds-since-2001.

## Screenshots

n/a — both fixes affect decode / message routing behavior, not UI
rendering.

## Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#1303

## Any other notes

Part of the Live Activities effort tracked in home-assistant/epics#61.
Companion server PR: home-assistant/core#166072.
2026-06-01 11:36:33 +02:00
..