https://github.com/douglasmakey/go-fcm
Firebase Cloud Messaging library written in Go
https://github.com/douglasmakey/go-fcm
fcm fcm-notifications firebase firebase-messaging golang
Last synced: 3 months ago
JSON representation
Firebase Cloud Messaging library written in Go
- Host: GitHub
- URL: https://github.com/douglasmakey/go-fcm
- Owner: douglasmakey
- License: mit
- Created: 2017-12-31T18:22:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-19T23:13:41.000Z (about 6 years ago)
- Last Synced: 2024-11-15T06:30:55.092Z (7 months ago)
- Topics: fcm, fcm-notifications, firebase, firebase-messaging, golang
- Language: Go
- Size: 17.6 KB
- Stars: 33
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-fcm : FCM library in Go
[](https://circleci.com/gh/douglasmakey/go-fcm)
[![Codecov]](https://codecov.io/gh/douglasmakey/go-fcm)Firebase Cloud Messaging ( FCM ) Library using golang ( Go )
This library uses HTTP/JSON Firebase Cloud Messaging connection server protocol
## Usage
```
go get github.com/douglasmakey/go-fcm
```## Docs
#### Firebase Cloud Messaging HTTP Protocol Specs
```
https://firebase.google.com/docs/cloud-messaging/http-server-ref
```#### Firebase Cloud Messaging Developer docs
```
https://firebase.google.com/docs/cloud-messaging/
```## Example
```go
package mainimport (
"log"
"github.com/douglasmakey/go-fcm"
)func main() {
// init client
client := fcm.NewClient("ApiKey")
// You can use your HTTPClient
//client.SetHTTPClient(client)
data := map[string]interface{}{
"message": "From Go-FCM",
"details": map[string]string{
"name": "Name",
"user": "Admin",
"thing": "none",
},
}
// You can use PushMultiple or PushSingle
client.PushMultiple([]string{"token 1", "token 2"}, data)
//client.PushSingle("token 1", data)
// registrationIds remove and return map of invalid tokens
badRegistrations := client.CleanRegistrationIds()
log.Println(badRegistrations)
status, err := client.Send()
if err != nil {
log.Fatalf("error: %v", err)
}
log.Println(status.Results)
}```
[Codecov]: https://codecov.io/gh/douglasmakey/go-fcm/branch/master/graph/badge.svg