Repository navigation
Simplify APNSRequest, share header derivation, and tidy alert init - #265
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cleanups from the codebase review. No behavior change; the existing header-propagation and encoding tests cover each path.
Changes
APNSRequestis a plain struct. The private copy-on-write class with@unchecked Sendable, acopy()method, and eight hand-writtenisKnownUniquelyReferencedaccessor pairs provided exactly the value semantics a struct with storedpublic varproperties already has. Public API is unchanged. Net 160 lines removed.APNSClient.sendusesAPNSRequest.headers. The NIO client had its own copy of theapns-*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, whichsendBroadcastalready did.APNSAlertNotificationEmptyPayloadinit delegates to the designated init instead of duplicating its body, so a newapsfield only needs to be threaded through once. The defaultapsstorage that every init immediately overwrote is gone.APNSBroadcastClientSendableconformance is unconditional. The class already constrainedDecoderandEncodertoSendable, so the conditional extension was redundant.Full suite: 154 tests, 0 failures.
Not included
The alert notification traps with a
preconditionon 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.