Skip to content

Commit

Permalink
Add support for new version of APNSwift (#51)
Browse files Browse the repository at this point in the history
* Update Package.swift

* Update Swift tools minimum version

* Rename to “VaporAPNS”

* Fix directory structure

* Rename tests target

* Update minimum platform versions

* Fix imports and exports

* Delete interactions with removed APNSwift features

* Export APNSCore

* Remove exports

* Fix imports in tests file

* Fix tests

---------

Co-authored-by: Kyle Browning <[email protected]>
  • Loading branch information
Gerzer and kylebrowning authored May 15, 2023
1 parent 263c835 commit 1637a30
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 32 deletions.
20 changes: 10 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// swift-tools-version:5.6
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "apns",
name: "vapor-apns",
platforms: [
.macOS(.v12),
.iOS(.v15)
.macOS(.v13),
.iOS(.v16)
],
products: [
.library(name: "APNS", targets: ["APNS"]),
.library(name: "VaporAPNS", targets: ["VaporAPNS"]),
],
dependencies: [
.package(url: "https://github.com/swift-server-community/APNSwift.git", from: "5.0.0-beta.2"),
.package(url: "https://github.com/swift-server-community/APNSwift.git", from: "5.0.0-beta.3"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
],
targets: [
.target(name: "APNS", dependencies: [
.product(name: "APNSwift", package: "apnswift"),
.target(name: "VaporAPNS", dependencies: [
.product(name: "APNS", package: "apnswift"),
.product(name: "Vapor", package: "vapor"),
]),
.testTarget(name: "APNSTests", dependencies: [
.target(name: "APNS"),
.testTarget(name: "VaporAPNSTests", dependencies: [
.target(name: "VaporAPNS"),
.product(name: "XCTVapor", package: "vapor"),
]),
]
Expand Down
5 changes: 0 additions & 5 deletions Sources/APNS/Exports.swift

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Vapor
import APNSwift
import APNS
import Foundation
import NIO
import NIOConcurrencyHelpers

public typealias APNSGenericClient = APNSClient<JSONDecoder, JSONEncoder>

Expand All @@ -24,7 +26,7 @@ public class APNSContainers {

private var containers: [ID: Container]
private var defaultID: ID?
private var lock: Lock
private var lock: NIOLock

init() {
self.containers = [:]
Expand Down Expand Up @@ -52,7 +54,6 @@ extension APNSContainers {
responseDecoder: JSONDecoder,
requestEncoder: JSONEncoder,
byteBufferAllocator: ByteBufferAllocator = .init(),
backgroundActivityLogger: Logger,
as id: ID,
isDefault: Bool? = nil
) {
Expand All @@ -66,8 +67,7 @@ extension APNSContainers {
eventLoopGroupProvider: eventLoopGroupProvider,
responseDecoder: responseDecoder,
requestEncoder: requestEncoder,
byteBufferAllocator: byteBufferAllocator,
backgroundActivityLogger: backgroundActivityLogger
byteBufferAllocator: byteBufferAllocator
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import APNSwift
import APNS
import NIOConcurrencyHelpers
import Vapor

extension Application {
Expand All @@ -9,7 +10,7 @@ extension Application {
public struct APNS {

// Synchronize access across threads.
private var lock: Lock
private var lock: NIOLock

struct ContainersKey: StorageKey, LockKey {
typealias Value = APNSContainers
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import APNSwift
import APNS
import Vapor

extension Request {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import APNS
import VaporAPNS
import XCTVapor

class APNSTests: XCTestCase {
Expand Down Expand Up @@ -29,7 +30,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .default
)

Expand All @@ -45,8 +45,7 @@ class APNSTests: XCTestCase {
topic: "MY_TOPC",
payload: Payload()
),
deviceToken: "98AAD4A2398DDC58595F02FA307DF9A15C18B6111D1B806949549085A8E6A55D",
deadline: .distantFuture
deviceToken: "98AAD4A2398DDC58595F02FA307DF9A15C18B6111D1B806949549085A8E6A55D"
)
return .ok
}
Expand Down Expand Up @@ -75,7 +74,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .default
)

Expand Down Expand Up @@ -105,7 +103,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .custom
)

Expand Down Expand Up @@ -140,7 +137,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .default,
isDefault: true
)
Expand All @@ -155,7 +151,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .custom,
isDefault: true
)
Expand Down Expand Up @@ -192,7 +187,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .default,
isDefault: true
)
Expand All @@ -207,7 +201,6 @@ class APNSTests: XCTestCase {
eventLoopGroupProvider: .createNew,
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
backgroundActivityLogger: app.logger,
as: .custom
)

Expand Down

0 comments on commit 1637a30

Please sign in to comment.