Skip to content

Commit

Permalink
Make Application.APNS an APNSwiftClient (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored Jan 9, 2020
1 parent cec35a4 commit afc9987
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Sources/APNS/Application+APNS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,40 @@ extension Application {
let application: Application
}
}

extension Application.APNS: APNSwiftClient {
public var logger: Logger? {
self.application.logger
}

public var eventLoop: EventLoop {
self.application.eventLoopGroup.next()
}

public func send(
rawBytes payload: ByteBuffer,
pushType: APNSwiftConnection.PushType,
to deviceToken: String,
expiration: Date?,
priority: Int?,
collapseIdentifier: String?,
topic: String?,
logger: Logger?
) -> EventLoopFuture<Void> {
self.application.apns.pool.withConnection(
logger: logger,
on: self.eventLoop
) {
$0.send(
rawBytes: payload,
pushType: pushType,
to: deviceToken,
expiration: expiration,
priority: priority,
collapseIdentifier: collapseIdentifier,
topic: topic,
logger: logger
)
}
}
}

0 comments on commit afc9987

Please sign in to comment.