Swiftpack.co - Package - mdab121/vapor-fcm

Vapor FCM

Build Status codebeat badge Platforms Package Managers License: MIT Twitter Follow

Simple Vapor framework for sending Firebase Cloud Messages.

:question: Why?

Do you want to write your awesome server in Swift using Vapor? At some point, you'll probably need to send Push Notifications to Android as well 😉

✅ Features

  • [x] Full message Payload support: badges and sounds for iOS
  • [x] Response parsing, instant send response feedback
  • [x] Custom data payload support
  • [x] Send message to Devices and Topics

Vapor Versions

  • [x] Use Vapor-FCM version 1.x for Vapor 1.x
  • [x] Use Vapor-FCM version 2.x for Vapor 2.x

💻 Installation

Swift Package Manager

.Package(url: "https://github.com/mdab121/vapor-fcm.git", majorVersion: 2, minor: 1)

🔢 Usage

Simple Example

Sending a simple FCM Message is really simple. Just create a Firebase object that will deliver your messages.

let firebase = try Firebase(drop: droplet, keyPath: "/path/to/your/key")

Create a Message

let payload = Payload(text: "Hello VaporFCM!")
let message = Message(payload: payload)

And now, simply send your message to a single device!

let token: DeviceToken = "this_is_a_device_token"
let response = try firebase.send(message: message, to: token)
if response.success {
	// Handle success
} else {
	// Handle error
}

You can also send messages to Topics

let topic: Topic = "cats"
let response = try firebase.send(message: message, to: topic)
if response.success {
	// Handle success
} else {
	// Handle error
}

Github

link
Stars: 19
Help us keep the lights on

Dependencies

Used By

Total: 0