Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rb-go/go-fcm
Optimized Firebase Cloud Messaging Package for Golang
https://github.com/rb-go/go-fcm
fcm firebase firebase-cloud-messaging golang google
Last synced: 5 days ago
JSON representation
Optimized Firebase Cloud Messaging Package for Golang
- Host: GitHub
- URL: https://github.com/rb-go/go-fcm
- Owner: rb-go
- License: mit
- Created: 2019-03-06T17:35:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-18T06:30:03.000Z (almost 5 years ago)
- Last Synced: 2024-06-19T19:39:46.594Z (5 months ago)
- Topics: fcm, firebase, firebase-cloud-messaging, golang, google
- Language: Go
- Size: 31.3 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# gofcm
(in beta but works in production :) )[![GoDoc](https://godoc.org/github.com/riftbit/gofcm?status.svg)](https://godoc.org/github.com/riftbit/gofcm)
[![Go Report Card](https://goreportcard.com/badge/github.com/riftbit/gofcm)](https://goreportcard.com/report/github.com/riftbit/gofcm)This project basicly was forked from [github.com/appleboy/go-fcm](https://github.com/appleboy/go-fcm).
## Difference with appleboy package
* [x] Go modules with semantic versioning
* [x] valyala/fasthttp client instead of net/http
* [x] mailru/easyjson client instead of encoding/json
* [x] Send() returns original body ([]byte) too (if FCM answer changed you can parse by yourself and not wait for package update)
* [x] Some optimizationsGolang client library for Firebase Cloud Messaging. Implemented only [HTTP client](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream).
More information on [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/)
## Feature
* [x] Send messages to a topic
* [x] Send messages to a device list
* [x] Supports condition attribute (fcm only)## Getting Started
To install gofcm, use `go get`:
```bash
go get github.com/riftbit/gofcm
```## Sample Usage
Here is a simple example illustrating how to use FCM library:
```go
package mainimport (
"log""github.com/riftbit/gofcm"
)func main() {
// Create the message to be sent.
msg := &fcm.Message{
To: "sample_device_token",
Data: map[string]interface{}{
"foo": "bar",
},
}// Create a FCM client to send the message.
client, err := fcm.NewClient("sample_api_key")
if err != nil {
log.Fatalln(err)
}// Send the message and receive the response without retries.
response, body, err := client.Send(msg)
if err != nil {
log.Fatalln(err)
}log.Printf("%#v\n", response)
log.Printf("%#v\n", body)
}
```