Skip to content

Simplify APNSRequest, share header derivation, and tidy alert init - #265

Merged
kylebrowning merged 1 commit into
mainfrom
refactor/client-cleanups
Oct 8, 2026
Merged

kylebrowning merged 1 commit into
mainfrom
refactor/client-cleanups

Conversation

@kylebrowning

Copy link
Copy Markdown
Owner

Cleanups from the codebase review. No behavior change; the existing header-propagation and encoding tests cover each path.

Changes

  • APNSRequest is a plain struct. The private copy-on-write class with @unchecked Sendable, a copy() method, and eight hand-written isKnownUniquelyReferenced accessor pairs provided exactly the value semantics a struct with stored public var properties already has. Public API is unchanged. Net 160 lines removed.
  • APNSClient.send uses APNSRequest.headers. The NIO client had its own copy of the apns-* header mapping while the URLSession client used the shared one. A new header added to one could silently miss the other. Both now derive from the same property, which sendBroadcast already did.
  • APNSAlertNotification EmptyPayload init delegates to the designated init instead of duplicating its body, so a new aps field only needs to be threaded through once. The default aps storage that every init immediately overwrote is gone.
  • APNSBroadcastClient Sendable conformance is unconditional. The class already constrained Decoder and Encoder to Sendable, so the conditional extension was redundant.

Full suite: 154 tests, 0 failures.

Not included

The alert notification traps with a precondition on an out-of-range relevance score while Live Activity notifications accept any value. Changing either direction is a behavior decision, so I left it alone.

- APNSRequest is now a plain struct with stored public properties. The
  copy-on-write class with @unchecked Sendable and eight hand-written accessor
  pairs was equivalent to value semantics the struct already provides.
- APNSClient.send derives apns-* headers from APNSRequest.headers, the same
  source the URLSession client uses, instead of a second hand-written mapping.
- APNSAlertNotification's EmptyPayload init delegates to the designated init,
  and the throwaway default aps storage is removed.
- APNSBroadcastClient's Sendable conformance is unconditional, matching the
  constraints already on the class.
@kylebrowning
kylebrowning merged commit 5698984 into main Oct 8, 2026
7 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