Skip to content
Optimized Firebase Cloud Messaging Package for Golang
Go Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
example
.gitignore
LICENSE
Makefile
README.md
client.go
client_test.go
go.mod
go.sum
helpers.go
message.go
message_easyjson.go
message_test.go
option.go
response.go
response_easyjson.go
response_test.go
retry.go
retry_test.go

README.md

gofcm

(in beta but works in production :) )

GoDoc Go Report Card

This project basicly was forked from github.com/appleboy/go-fcm.

Difference with appleboy package

  • Go modules with semantic versioning
  • valyala/fasthttp client instead of net/http
  • mailru/easyjson client instead of encoding/json
  • Send() returns original body ([]byte) too (if FCM answer changed you can parse by yourself and not wait for package update)
  • Some optimizations

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

More information on Firebase Cloud Messaging

Feature

  • Send messages to a topic
  • Send messages to a device list
  • Supports condition attribute (fcm only)

Getting Started

To install gofcm, use go get:

go get github.com/riftbit/gofcm

Sample Usage

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

package main

import (
	"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)
}
You can’t perform that action at this time.