push

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyMapper = emptyMapper(0)

EmptyMapper is a Mapper which always returns a empty map.

Variables

This section is empty.

Functions

This section is empty.

Types

type APNSPusher

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

APNSPusher pushes notification via apns

func NewAPNSPusher

func NewAPNSPusher(connOpener func() (skydb.Conn, error), gwType GatewayType, cert string, key string) (*APNSPusher, error)

NewAPNSPusher returns a new APNSPusher from content of certificate and private key as string

func (*APNSPusher) Run

func (pusher *APNSPusher) Run()

Run listens to the notification error channel

func (*APNSPusher) Send

func (pusher *APNSPusher) Send(m Mapper, device skydb.Device) error

Send sends a notification to the device identified by the specified device

func (*APNSPusher) Stop

func (pusher *APNSPusher) Stop()

type GCMPusher

type GCMPusher struct {
	APIKey string
}

GCMPusher sends push notifications via GCM.

func (*GCMPusher) Send

func (p *GCMPusher) Send(m Mapper, device skydb.Device) error

Send sends the dictionary represented by m to device.

type GatewayType

type GatewayType string

GatewayType determine which kind of gateway should be used for APNS

const (
	Sandbox    GatewayType = "sandbox"
	Production             = "production"
)

Available gateways

type MapMapper

type MapMapper map[string]interface{}

MapMapper is a string-interface map that implemented the Mapper interface.

func (MapMapper) Map

func (m MapMapper) Map() map[string]interface{}

Map returns the map itself.

type Mapper

type Mapper interface {
	// Implementor of Map should return a string-interface map which
	// all values are JSON-marshallable
	Map() map[string]interface{}
}

Mapper defines a single method Map()

type RouteSender

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

RouteSender routes notifications to registered senders that is capable of sending them. RouteSender itself doesn't send notifications.

func NewRouteSender

func NewRouteSender() RouteSender

NewRouteSender return a new RouteSender.

func (RouteSender) Len

func (s RouteSender) Len() int

Len returns the number of services registered with sender.

func (RouteSender) Route

func (s RouteSender) Route(service string, sender Sender)

Route registers a sender to handle notifications sent via a certain Push Notification Service.

func (RouteSender) Send

func (s RouteSender) Send(m Mapper, device skydb.Device) error

Send inspects device and route notification (m) to corresponding sender.

type Sender

type Sender interface {
	Send(m Mapper, device skydb.Device) error
}

Sender defines the methods that a push service should support.

Jump to

Keyboard shortcuts

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