fcm

package module
v0.0.0-...-4221ec8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2017 License: Apache-2.0 Imports: 0 Imported by: 0

README

fcm

Firebase Cloud Messaging(fcm) client.

How to use

Get!

$ go get github.com/mokelab-go/fcm

Write!

package main

import (
  "fmt"
  fcm "github.com/mokelab-go/fcm/impl"
)

const (
  apiKey = "INPUT YOUR API_KEY"
  regID = "INPUT YOUR REG_ID"
)

func main() {
	client := fcm.NewClient(apiKey)
	notification := fcm.Notification{
		Title: "test",
		Body:  "hello",
	}
	data := fcm.Data{
		"name": "moke",
	}
	_, err := client.Send(notification, data, regID)
	if err != nil {
		t.Errorf("Failed to send FCM message : %s", err)
	}
} 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {

	// Send FCM message to FCM server.
	Send(notification Notification, data Data, regIds ...string) (Response, error)
}

Client is an interface for FCM server.

type Data

type Data map[string]interface{}

Data is a "data" section in FCM message.

type Notification

type Notification struct {
	Title       string
	Body        string
	Icon        string
	Sound       string
	Badge       string
	Tag         string
	Color       string
	ClickAction string
}

Notification is a "notification" section in FCM message

func (*Notification) ToMap

func (n *Notification) ToMap() map[string]interface{}

ToMap coverts to map[string]interface{}

type Response

type Response struct {
}

Response is a response of FCM server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL