Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 964 Bytes

File metadata and controls

41 lines (32 loc) · 964 Bytes

go-pushy

This package is a golang client for pushy.me.

Supported APIs

Usage

go get github.com/healthimation/go-pushy/pushy
import (
    "log"
    "time"

    "github.com/healthimation/go-pushy/pushy"
)

func main() {
    timeout := 5 * time.Second
    client := pushy.NewClient("my pushy api key", timeout)

    // push to devices
    tokens := []string{"device_token1", "device_token2"}
    data := map[string]string{"msg": "hello world!"}
    pushID, err := client.PushToDevices(context.Background(), tokens, data, nil) 
    if err != nil {
        log.Printf("Error pushing to devices: %s", err.Error())
    }

    // push to a topic
    topic := "current_events"
    pushID, err := client.PushToTopic(context.Background(), topic, data, nil)
    if err != nil {
        log.Printf("Error pushing to topic: %s", err.Error())
    }
}