Skip to content

Mark APNSResponse and APNSErrorResponse as Sendable #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/APNSCore/APNSErrorResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// A struct for the error response of APNs.
///
/// This is just used to decode the JSON and should not be exposed.
public struct APNSErrorResponse: Codable {
public struct APNSErrorResponse: Codable, Sendable {
/// The error code indicating the reason for the failure.
public var reason: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/APNSCore/APNSResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import struct Foundation.UUID

/// The response of a successful APNs request.
public struct APNSResponse: Hashable {
public struct APNSResponse: Hashable, Sendable {
/// The same value as the `apnsID` send in the request.
///
/// Use this value to identify the notification. If you don’t specify an `apnsID` in your request,
Expand Down
15 changes: 15 additions & 0 deletions Tests/APNSTests/APNSClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,18 @@ final class APNSClientTests: XCTestCase {
-----END PRIVATE KEY-----
"""
}

// This doesn't perform any runtime tests, it just ensures the call to sendAlertNotification
// compiles when called within an actor's isolation context.
actor TestActor {
func sendAlert(client: APNSClient<JSONDecoder, JSONEncoder>) async throws {
let notification = APNSAlertNotification(
alert: .init(title: .raw("title")),
expiration: .immediately,
priority: .immediately,
topic: "",
payload: ""
)
try await client.sendAlertNotification(notification, deviceToken: "")
}
}