Skip to content

Tidy broadcast channel model and harden broadcast/error handling#244

Merged
kylebrowning merged 1 commit into
mainfrom
cleanup/broadcast-model-and-errors
Jun 26, 2026
Merged

Tidy broadcast channel model and harden broadcast/error handling#244
kylebrowning merged 1 commit into
mainfrom
cleanup/broadcast-model-and-errors

Conversation

@kylebrowning

Copy link
Copy Markdown
Owner

Changes

APNSBroadcastChannel

Drop the redundant second initializer. It was public, duplicated init(messageStoragePolicy:), and its pushType: parameter was misleading — only "LiveActivity" is supported, and decoding a channel from an APNs response goes through the synthesized Codable conformance, not this init.

APNSBroadcastClient.send

Previously decoded the success body with try?, silently turning a malformed read/listAll body into nil. Now it decodes only when bytes are present and propagates decode failures. Empty create/delete bodies still map to a nil body as before.

Tests

New APNSErrorReasonTests:

  • round-trips every known reason string ↔ enum case (string mapping had no coverage)
  • verifies the .unknown fallback preserves the raw string
  • guards that BadEnvironmentKeyInToken and BadEnvironmentKeyIdInToken (differ by Id) stay distinct
  • covers the decoded-APNSErrorResponse → typed reason path

Testing

swift test — 76 tests pass.

- APNSBroadcastChannel: drop the redundant second initializer. It was public,
  duplicated `init(messageStoragePolicy:)`, and its `pushType:` parameter was
  misleading (only "LiveActivity" is supported, and decoding goes through the
  synthesized Codable conformance, not this init).
- APNSBroadcastClient.send: only decode a success body when bytes are present,
  and propagate decode failures instead of swallowing them with `try?` (which
  silently turned a malformed read/list body into `nil`). Empty create/delete
  bodies still map to a `nil` body as before.
- Add APNSErrorReasonTests: round-trips every known reason string, checks the
  unknown fallback is preserved, asserts BadEnvironmentKeyInToken vs
  BadEnvironmentKeyIdInToken stay distinct, and covers the decoded-response path.
@kylebrowning kylebrowning merged commit 81eb92b into main Jun 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant