package
0.0.0-20190806085950-af561f6ff7a1
Repository: https://github.com/kylebanks/go-kit.git
Documentation: pkg.go.dev

# README

push

-- import "github.com/KyleBanks/go-kit/push/"

Package push provides GCM and APN push notification functionality.

Usage

const (
	// ApnsEndpointSandbox is the endpoint of the sandbox APNS service.
	ApnsEndpointSandbox = "gateway.sandbox.push.apple.com"

	// ApnsEndpointProduction is the endpoint of the production APNS service.
	ApnsEndpointProduction = "gateway.push.apple.com"

	// ApnsPort is the port of the APNS service.
	ApnsPort = 2195

	// IosDefaultSound is the name of the default sound to play for iOS notifications.
	IosDefaultSound = "default"
)
const (
	// MaxRetries defines the number of times to retry message sender if an error occurs.
	MaxRetries = 2
)

type AndroidPusher

type AndroidPusher struct {
}

AndroidPusher supports sending of GCM push notifications to Android devices.

func NewAndroidPusher

func NewAndroidPusher(apiKey string) *AndroidPusher

NewAndroidPusher returns an AndroidPusher, initialized with the specified GCM API key.

func (*AndroidPusher) SendMessage

func (a *AndroidPusher) SendMessage(message *Message, deviceIds ...string) error

SendMessage sends a JSON payload to the specified DeviceIds through the GCM service.

type IosPusher

type IosPusher struct {
}

IosPusher supports sending of APNS push notifications to iOS devices.

func NewIosPusher

func NewIosPusher(isProd bool, certificateFile string, keyFile string) *IosPusher

NewIosPusher returns an IosPusher, initialized with the specified certificate and key files.

func (*IosPusher) SendMessage

func (i *IosPusher) SendMessage(message *Message, deviceIds ...string) error

SendMessage sends a JSON payload to the specified DeviceIds through the APNS service.

type Message

type Message struct {

	// Content is the title or content to be displayed to the user.
	Content string

	// Data contains any additional data to be sent with the notification.
	Data map[string]interface{}

	// IosSound is the sound to play for iOS devices specifically.
	IosSound string
}

Message defines a push message payload to be send to the client.

type Pusher

type Pusher interface {

	// SendMessage sends the payload provided as a JSON string to the deviceIds.
	SendMessage(message *Message, deviceIds string) error
}

Pusher defines the interface for a push notification Pusher.