Skip to content

Commit

Permalink
Add new init function for OneSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
vkill committed Aug 23, 2019
1 parent a6f7eab commit b2e00b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ let message = OneSignalMessage("Hello Vapor!")
let notif = OneSignalNotification(message: message, users: deviceTokens)
let app = OneSignalApp(apiKey: apiKey, appId: appId)

let resultFuture = try OneSignal().send(notification: notif, toApp: app)
let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1).next()
let resultFuture = try OneSignal(on: eventLoop).send(notification: notif, toApp: app)
```
8 changes: 6 additions & 2 deletions Sources/OneSignal/OneSignal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import NIO
public final class OneSignal {
let httpClient: HTTPClient

public init(httpClient: HTTPClient? = nil) {
self.httpClient = httpClient ?? HTTPClient(eventLoopGroupProvider: .createNew)
public init(httpClient: HTTPClient) {
self.httpClient = httpClient
}

public init(on eventLoop: EventLoop) {
self.httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoop))
}

deinit {
Expand Down

0 comments on commit b2e00b5

Please sign in to comment.