fcm

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

Usage Example

func main() {
   cfg := &FCMConfig{
		Cfg: Config{
			AuthJsonPath: "<Auth>.json",
			ProjectId:    "<Project ID>",
		},
	}
	ctx:=context.Background()
	c, err := NewClient(ctx,cfg)
	if err != nil {
		fmt.Printf(err.Error())
	}

	response, err := c.SendByToken(ctx, &Message{
		Notification: &Notification{
			Title: "Title",
			Body:  "Body",
		},
		Token: <Client Token>,
	})

	if err != nil {
		fmt.Printf(err.Error())
	}

	fmt.Printf("Response %s", response)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AuthJsonPath string
	ProjectId    string
}

type FCMClient

type FCMClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, cfg *FCMConfig) (*FCMClient, error)

func (*FCMClient) Send

func (fcmClient *FCMClient) Send(ctx context.Context, m *Message) (string, error)

type FCMConfig

type FCMConfig struct {
	Cfg Config
}

type Message

type Message struct {
	Data         map[string]string `json:"data,omitempty"`
	Notification *Notification     `json:"notification,omitempty"`
	Token        string            `json:"token,omitempty"`
	Topic        string            `json:"topic,omitempty"`
}

type Notification

type Notification struct {
	Title    string `json:"title,omitempty"`
	Body     string `json:"body,omitempty"`
	ImageURL string `json:"image,omitempty"`
}

Jump to

Keyboard shortcuts

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