Simple Vapor framework for sending Firebase Cloud Messages.
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 😉
- Full message Payload support: badges and sounds for iOS
- Response parsing, instant send response feedback
- Custom data payload support
- Send message to Devices and Topics
- Use Vapor-FCM version
1.x
for Vapor1.x
- Use Vapor-FCM version
2.x
for Vapor2.x
.Package(url: "https://github.com/mdab121/vapor-fcm.git", majorVersion: 2, minor: 1)
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
}