Tidy broadcast channel model and harden broadcast/error handling#244
Merged
Conversation
- 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.
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.
Changes
APNSBroadcastChannelDrop the redundant second initializer. It was
public, duplicatedinit(messageStoragePolicy:), and itspushType:parameter was misleading — only"LiveActivity"is supported, and decoding a channel from an APNs response goes through the synthesizedCodableconformance, not this init.APNSBroadcastClient.sendPreviously decoded the success body with
try?, silently turning a malformedread/listAllbody intonil. Now it decodes only when bytes are present and propagates decode failures. Emptycreate/deletebodies still map to anilbody as before.Tests
New
APNSErrorReasonTests:.unknownfallback preserves the raw stringBadEnvironmentKeyInTokenandBadEnvironmentKeyIdInToken(differ byId) stay distinctAPNSErrorResponse→ typed reason pathTesting
swift test— 76 tests pass.