Best android open-source packages and libraries.

Go fcm

Firebase Cloud Messaging Library for Golang
Updated 3 weeks ago

go-fcm

GoDoc Lint and Testing Go Report Card

This project was forked from github.com/edganiukov/fcm.

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

More information on Firebase 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 fcm, use go get:

go get github.com/appleboy/go-fcm

Sample Usage

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

package main

import (
  "log"

  "github.com/appleboy/go-fcm"
)

func main() {
  // Create the message to be sent.
  msg := &fcm.Message{
    To: "sample_device_token",
    Data: map[string]interface{}{
      "foo": "bar",
    },
    Notification: &fcm.Notification{
      Title: "title",
      Body: "body",
    },
  }

  // 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, err := client.Send(msg)
  if err != nil {
    log.Fatalln(err)
  }

  log.Printf("%#v\n", response)
}
Tags firebase fcm