Skip to content
/ fcm Public

Golang client library for Firebase Cloud Messaging.

License

Notifications You must be signed in to change notification settings

edganiukov/fcm

Repository files navigation

fcm

GoDoc Build Status Go Report Card

Golang client library for Firebase Cloud Messaging. Implemented only HTTP client.

More information on Firebase Cloud Messaging

Getting Started


To install fcm, use go get:

go get github.com/edganiukov/fcm

or dep, add to the Gopkg.toml file dependency:

[[constraint]]
  name = "github.com/edganiukov/fcm"
  version = "0.3.0"

and then run:

dep ensure

Sample Usage


Here is a simple example illustrating how to use FCM library:

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, err := fcm.NewClient("sample_api_key")
	if err != nil {
  		log.Fatal(err)
	}

	// 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.