Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

ez-connect/go-fcm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED - no longer actively maintained


Firebase Cloud Messaging

Golang client library for Firebase Cloud Messaging. It uses Firebase Cloud Messaging HTTP protocol: https://firebase.google.com/docs/cloud-messaging/http-server-ref.

Getting Started

$ go get github.com/ez-connect/go-fcm

Send message

// Create a client
client := NewClient("your-sever-key")

// New message
message := Message{
    To: "device-token-or-topic", // /topics/topic-name
    Notification: Notification{
        Title: "Title",
        Body:  "Body",
    },
}

// Send the message
resp, err := client.Send(message)
if err != nil {
    fmt.Println(resp)
}

Subscribe

// Subscribe
err := client.SubscribeToTopic([]string{"device-token"}, "/topics/test-topic-name")

// Unsubscribe
err = client.UnsubscribeFromTopic([]string{"device-token"}, "/topics/test-topic-name")

Device Info

// Get device info
info, err := client.GetDeviceInfo("device-token")
if err != nil {
    fmt.Println(info)
}

About

Firebase Cloud Message for Golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages