Swiftpack.co - Package - code28/vapor-gorush

Gorush Service for Vapor

This service allows to easily integrate Gorush into Vapor to send push notifications.

Installation

Add the package to the Package.swift

.package(url: "https://github.com/code28/vapor-gorush.git", from: "0.3.0")
// ...
.target(name: "App", dependencies: ["Vapor", "Gorush"])

Register Gorush in configure.swift

let hostname = Environment.get("GORUSH_HOSTNAME")
let port = Environment.get("GORUSH_PORT")
services.register(Gorush.self) { container in
    return Gorush(hostname: hostname, port: port)
}

Per default, HTTPS will be used. To use HTTP instead, just add httpScheme: .http into that initialization.

Usage

import Gorush
// ...
let notification = GorushNotification(tokens: ["deviceToken"], platform: .ios, message: "Push message", title: "Push title")

let gorush = container.make(Gorush.self)
gorush.dispatch(notification, on: worker).map { (response: GorushResponse) in
    if !response.logs.isEmpty {
        // This means an error occurred, if Gorush was configured to return errors
    }
}
// ...

License

This vapor-gorush package is released under an MIT license. See License for more information.

Todo

  • [ ] Parse Gorush response and answer with succeeded or failed future
  • [ ] Write further documentation
  • [ ] Complete fields for Gorush notification
  • [ ] Write tests

Github

link
Stars: 1
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

0.2.1 - Feb 21, 2019

⚠️ Breaking changes: Changes the return type inside the Future from HTTPResponse to GorushResponse, which can be useful for evaluating the success

0.2.0 - Feb 21, 2019

⚠️ Breaking changes: Changes the return type inside the Future from HTTPResponse to GorushResponse, which can be useful for evaluating the success

0.1.0 - Jan 15, 2019

First release with basic functionality