Swiftpack.co - Package - nodes-vapor/push-urban-airship


Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

Send push notifications with Urban Airship for Vapor.

ðŸ“Ķ Installation

Install package using SPM

Update your Package.swift file.

Swift 3

.Package(url: "https://github.com/nodes-vapor/push-urban-airship.git", majorVersion: 2)

Swift 4

.package(url: "https://github.com/nodes-vapor/push-urban-airship.git", .upToNextMajor(from: "2.0.1"))
targets: [
        name: "App",
        dependencies: [


Create config file uapusher.json with following syntax

    "applicationGroups": {
        "defaultGroup": {
            "development": {
                "appKey": "yyyy",
                "masterSecret": "yyyy"
            "staging": {
                "appKey": "yyyy",
                "masterSecret": "yyyy"

You can define multiple apps like in the example. Else just delete one of groups.

Getting started 🚀

Set up the provider:

import UAPusher

try config.addProvider(UAPusher.Provider.self)

Simple example

let body = try JSON(node: [
    "audience": "all",
    "device_types": [
    "notification": [
        "alert": "hello world"
let request = UARequest(body: body)

do {
    let response = try drop.uapusher?.send(request: request)
    if response.status == .accepted {
        print("Push sent..")
} catch UAError.response(let uaResponse) {
    // let response = uaResponse.response[0]

The above example will send a text push notification with the message hello world to all users on the ios platform.

Chain your payload

This package offers a way to easily customize the different segments of the payload sent to Urban Airship, using the UABuilder class.

let payload: JSON = try UABuilder()
    .add(Notification(.alert(value:"this is a test")))
let request: UARequest = UARequest(body: payload)

You can also provide all segments in a list

let payload: JSON = try UABuilder().add([
    Notification(.alert(value:"this is a test"))
let request: UARequest = UARequest(body: payload)

The above examples will define a text push notification with the message this is a test to all users.

UABuilder currently lets you set audience, campaigns, device_type, ÃŽn_app, message and notification. Method overloads allow you to set the payload segments directly using custom JSON or using a preset value. For more information see the Urban Airship documentation about the push object or check out the full api documentation.

🏆 Credits

This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Rasmus.

📄 License

This package is open-sourced software licensed under the MIT license.


Stars: 6
Help us keep the lights on



2.0.2 - Mar 20, 2018


  • Stop resolving client from droplet.json and start using FoundationClientFactory() right away.

2.0.1 - Jan 24, 2018

  • Fixes runtime crash by postponing resolving of the client and cache

2.0.0 - Jan 22, 2018

  • remove dependency on Droplet
  • fix type in ConnectionManager class + file

1.1.0 - Jan 3, 2018


  • Segment class for Audience
  • Segment class for Campaigns
  • Segment class for DeviceTypes
  • Segment class for InApp messages
  • Segment class for rich push messages
  • Segment class for regular push notifications
  • Segment class for options
  • Builder class for defining a compound payload from segments


  • Minor changes in file structure

1.0.0 - May 29, 2017

  • Vapor 2 released 🎉