Skip to content

8.0.0-beta1

Pre-release
Pre-release

Choose a tag to compare

@kylebrowning kylebrowning released this 16 Oct 21:08
· 1 commit to main since this release
966909e

APNSwift 8 runs as a swift-service-lifecycle Service, so you can drop it into Hummingbird, Vapor 5, or any ServiceGroup with no glue package. It also raises the platform and toolchain minimums and removes the APIs deprecated in 7.x.

8.0.0 includes everything in 7.1.0.

Breaking changes

  • Swift 6.1 or later is required. Swift 5.10 projects can stay on 7.1.0.

  • Minimum platforms are now macOS 15, iOS 18, watchOS 11 and tvOS 18.

  • APNSClient requires Sendable coders, as APNSBroadcastClient already did. JSONEncoder and JSONDecoder are Sendable, so most code needs no changes. (#270)

  • Removed deprecated APIs (#271):

    Removed Use instead
    APNSEnvironment.sandbox .development
    P256.Signing.PrivateKey.loadFrom(string:) P256.Signing.PrivateKey(pemRepresentation:)
    sendWidgetsNotification(notification:deviceToken:) sendWidgetsNotification(_:deviceToken:)
    APNSError.ErrorReason.badEnvironmentKeyInToken .badEnvironmentKeyIdInToken

    Apple doesn't document a BadEnvironmentKeyInToken reason. If a response ever contains it, it now decodes as .unknown("BadEnvironmentKeyInToken").

  • APNSExample is no longer a library product. It's still in the repo as an example target. (#271)

New

swift-service-lifecycle support (#270)

APNSClient, APNSBroadcastClient and the new APNSClients conform to Service. Add one to your service group, and it shuts down when the group does.

Hummingbird:

var app = Application(router: router)
app.addServices(client)
try await app.runService()

Vapor 5:

let app = try Application()
app.addService(client)
try await app.start()

This support comes from the ServiceLifecycleSupport package trait, which is on by default. To skip the dependency, turn the trait off:

.package(url: "https://github.com/kylebrowning/APNSwift.git", from: "8.0.0", traits: []),

APNSClients (#270)

APNSClients holds a set of clients looked up by ID. It's ported from vapor/apns with the Vapor-specific parts removed. configure(_:) registers a production and a development client from one key:

let apns = APNSClients()
apns.configure(.jwt(
    privateKey: try .init(pemRepresentation: privateKey),
    keyIdentifier: keyIdentifier,
    teamIdentifier: teamIdentifier
))

try await apns.client(.development).sendAlertNotification(notification, deviceToken: token)

Smaller improvements (#271)

  • eventLoopGroupProvider now defaults to .shared(MultiThreadedEventLoopGroup.singleton) on APNSClient and APNSBroadcastClient, so you can leave it out. The docs no longer recommend the deprecated .createNew.

Full changelog: 7.1.0...8.0.0