sns

package
v0.0.0-...-4347b6b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeEnabled            = "Enabled"
	AttributeToken              = "Token"
	AttributeEndpointCreated    = "EventEndpointCreated"
	AttributeEndpointDeleted    = "EventEndpointDeleted"
	AttributeEndpointUpdated    = "EventEndpointUpdated"
	AttributeDeliveryFailure    = "EventDeliveryFailure"
	AttributePlatformCredential = "PlatformCredential"
	AttributePlatformPrincipal  = "PlatformPrincipal"
)

Message Attributes.

View Source
const (
	TypeDeliveryFailure = "DeliveryFailure"
	TypeNotification    = "Notification"
)

Message Types.

Variables

View Source
var (
	ErrDeliveryFailure  = errors.New("delivery failed")
	ErrEndpointDisabled = errors.New("endppint disabled")
	ErrEndpointNotFound = errors.New("endpoint not found")
)

Common errors for Device serive implementations and validations.

View Source
var PlatformIdentifiers = map[Platform]string{
	PlatformAPNS:        "APNS",
	PlatformAPNSSandbox: "APNS_SANDBOX",
	PlatformGCM:         "GCM",
}

PlatformIdentifiers helps to map Platfrom to human-readable strings.

Functions

func IsDeliveryFailure

func IsDeliveryFailure(err error) bool

IsDeliveryFailure indicates if err is ErrDeliveryFailure

func IsEndpointDisabled

func IsEndpointDisabled(err error) bool

IsEndpointDisabled indicates if err is ErrEndpointDisabled.

func IsEndpointNotFound

func IsEndpointNotFound(err error) bool

IsEndpointNotFound indicates if err is ErrEndpointNotFound.

Types

type API

API bundles common SNS interactions in a reasonably sized interface.

type AppCreateAPNSFunc

type AppCreateAPNSFunc func(name, cert, key string) (string, error)

AppCreateAPNSFunc creates a new platform application for APNS production.

func AppCreateAPNS

func AppCreateAPNS(api API, changeTopic string) AppCreateAPNSFunc

AppCreateAPNS creates a new platform application for APNS production.

type AppCreateAPNSSandboxFunc

type AppCreateAPNSSandboxFunc func(name, cert, key string) (string, error)

AppCreateAPNSSandboxFunc creates a new platform application for APNS sandbox.

func AppCreateAPNSSandbox

func AppCreateAPNSSandbox(api API, changeTopic string) AppCreateAPNSSandboxFunc

AppCreateAPNSSandbox creates a new platform application for APNS sandbox.

type AppCreateGCMFunc

type AppCreateGCMFunc func(name, key string) (string, error)

AppCreateGCMFunc creates a new platform application for GCM.

func AppCreateGCM

func AppCreateGCM(api API, changeTopic string) AppCreateGCMFunc

AppCreateGCM creates a new platform application for GCM.

type Endpoint

type Endpoint struct {
	ARN   string
	Token string
}

Endpoint is the AWS SNS representation of a Device.

type EndpointCreateFunc

type EndpointCreateFunc func(platformARN, token string) (*Endpoint, error)

EndpointCreateFunc registers a new device endpoint for the given platform and token.

func EndpointCreate

func EndpointCreate(api API) EndpointCreateFunc

EndpointCreate registers a new device endpoint for the given platform and token.

type EndpointRetrieveFunc

type EndpointRetrieveFunc func(arn string) (*Endpoint, error)

EndpointRetrieveFunc returns the Endpoint for the given ARN.

func EndpointRetrieve

func EndpointRetrieve(api API) EndpointRetrieveFunc

EndpointRetrieve returns the Endpoint for the given ARN.

type EndpointUpdateFunc

type EndpointUpdateFunc func(arn, token string) (*Endpoint, error)

EndpointUpdateFunc takes a new token and stores it with the Endpoint.

func EndpointUpdate

func EndpointUpdate(api API) EndpointUpdateFunc

EndpointUpdate takes a new token and stores it with the Endpoint.

type Error

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

Error wraps common Device errors.

func (Error) Error

func (e Error) Error() string

type Platform

type Platform uint8

Platform of a device.

const (
	PlatformAPNSSandbox Platform = iota + 1
	PlatformAPNS
	PlatformGCM
)

Platform supported by SNS for push.

type PushFunc

type PushFunc func(
	platform Platform,
	endpointARN, scheme, urn, message string,
) error

PushFunc pushes a new notification to the device for the given endpoint ARN.

func Push

func Push(api API) PushFunc

Push pushes a new notification to the device for the given endpoint ARN.

Jump to

Keyboard shortcuts

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