2017-06-01 07:52:01 +00:00
|
|
|
# go-fcm
|
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
[![GoDoc](https://godoc.org/github.com/edganiukov/fcm?status.svg)](https://godoc.org/github.com/edganiukov/fcm)
|
|
|
|
[![Build Status](https://travis-ci.org/edganiukov/fcm.svg?branch=master)](https://travis-ci.org/edganiukov/fcm)
|
|
|
|
[![Go Report Card](https://goreportcard.com/badge/github.com/edganiukov/fcm)](https://goreportcard.com/report/github.com/edganiukov/fcm)
|
|
|
|
|
2017-06-01 07:52:01 +00:00
|
|
|
This project was forked from [github.com/edganiukov/fcmfcm](https://github.com/edganiukov/fcm).
|
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
Golang 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/)
|
|
|
|
|
2017-06-01 07:52:01 +00:00
|
|
|
## Getting Started
|
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
To install fcm, use `go get`:
|
|
|
|
|
|
|
|
```bash
|
2017-06-01 07:52:01 +00:00
|
|
|
go get github.com/appleboy/go-fcm
|
2017-06-01 03:56:10 +00:00
|
|
|
```
|
2017-06-01 07:52:01 +00:00
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
or `govendor`:
|
|
|
|
|
|
|
|
```bash
|
2017-06-01 07:52:01 +00:00
|
|
|
govendor fetch github.com/appleboy/go-fcm
|
2017-06-01 03:56:10 +00:00
|
|
|
```
|
2017-06-01 07:52:01 +00:00
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
or other tool for vendoring.
|
|
|
|
|
2017-06-01 07:52:01 +00:00
|
|
|
## Sample Usage
|
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
Here is a simple example illustrating how to use FCM library:
|
2017-06-01 07:52:01 +00:00
|
|
|
|
2017-06-01 03:56:10 +00:00
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/edganiukov/fcm"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// Create the message to be sent.
|
|
|
|
msg := &fcm.Message{
|
|
|
|
Token: "sample_device_token",
|
|
|
|
Data: map[string]interface{}{
|
|
|
|
"foo": "bar",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a FCM client to send the message.
|
|
|
|
client := fcm.NewClient("sample_api_key")
|
|
|
|
|
|
|
|
// Send the message and receive the response without retries.
|
|
|
|
response, err := client.Send(msg)
|
|
|
|
if err != nil {
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### TODO:
|
|
|
|
---------
|
|
|
|
- [ ] Retry only failed messages while multicast messaging.
|