sns

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppTypeAPNS        = "APNS"
	AppTypeAPNSSandbox = "APNS_SANDBOX"
	AppTypeGCM         = "GCM"

	ProtocolApplication = "application"
)

Application types

Variables

This section is empty.

Functions

func ParseARNFromError

func ParseARNFromError(err error) (arn string, ok bool)

ParseARNFromError extracts ARN string from error message.

Types

type PlatformApplication

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

PlatformApplication is struct for Platform Application.

func (*PlatformApplication) CreateEndpoint

func (a *PlatformApplication) CreateEndpoint(token string) (*PlatformEndpoint, error)

CreateEndpoint creates Endpoint(add device).

func (*PlatformApplication) CreateEndpointWithUserData

func (a *PlatformApplication) CreateEndpointWithUserData(token, userData string) (*PlatformEndpoint, error)

CreateEndpointWithUserData creates Endpoint(add device) with CustomUserData.

func (*PlatformApplication) SetUserData

func (a *PlatformApplication) SetUserData(userData string)

SetUserData sets CustomUserData.

type PlatformEndpoint

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

PlatformEndpoint is struct for Platform Endpoint.

func (*PlatformEndpoint) Enable

func (e *PlatformEndpoint) Enable() bool

Enable returns info that endpoint is Enable or not.

func (*PlatformEndpoint) GetARN

func (e *PlatformEndpoint) GetARN() (endpointARN string)

GetARN returns endpoint ARN.

func (*PlatformEndpoint) GetToken

func (e *PlatformEndpoint) GetToken() (token string)

GetToken returns endpoint Token.

func (*PlatformEndpoint) Publish

func (e *PlatformEndpoint) Publish(msg string, badge int) error

Publish sends push notification to the endpoint.

func (*PlatformEndpoint) PublishWithOption

func (e *PlatformEndpoint) PublishWithOption(msg string, opt map[string]interface{}) error

PublishWithOption sends push notification to the endpoint with optional params.

func (*PlatformEndpoint) UpdateAsDisable

func (e *PlatformEndpoint) UpdateAsDisable() error

UpdateAsDisable updates as `Enabled` is false.

func (*PlatformEndpoint) UpdateToken

func (e *PlatformEndpoint) UpdateToken(token string) error

UpdateToken updates token and `Enabled` is true.

type Platforms

type Platforms struct {
	Production bool

	Apple  string
	Google string
}

Platforms contations Platforms Application ARNs.

func (Platforms) GetARNByType

func (p Platforms) GetARNByType(typ string) (arn string)

GetARNByType returns ARN for application platform by device type.

type SNS

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

SNS is AWS SNS client and has platform application and topic list.

func New

func New(conf config.Config, pf Platforms) (*SNS, error)

New returns initialized *SNS. use ARNs in given Platforms.

func (*SNS) BulkPublish

func (svc *SNS) BulkPublish(tokens map[string][]string, msg string) error

BulkPublish sends mobile notification for many endpoints. tokens is map of string slices, each key stands for device, like "android"/"ios" ex) tokens := map[string][]string{ "android": []string{"token1", "token2"}, "ios": []string{"token3", "token4"}}

func (*SNS) BulkPublishByDevice

func (svc *SNS) BulkPublishByDevice(device string, tokens []string, msg string) error

BulkPublishByDevice sends mobile notification to many endpoints. (supports single device only)

func (*SNS) CreateTopic

func (svc *SNS) CreateTopic(name string) (*Topic, error)

CreateTopic creates Topic.

func (*SNS) Errorf

func (svc *SNS) Errorf(format string, v ...interface{})

Errorf logging error information.

func (*SNS) GetEndpoint

func (svc *SNS) GetEndpoint(arn string) (*PlatformEndpoint, error)

GetEndpoint gets *PlatformEndpoint by ARN.

func (*SNS) GetPlatformApplicationApple

func (svc *SNS) GetPlatformApplicationApple() *PlatformApplication

GetPlatformApplicationApple returns *PlatformApplication for iOS APNS.

func (*SNS) GetPlatformApplicationGoogle

func (svc *SNS) GetPlatformApplicationGoogle() *PlatformApplication

GetPlatformApplicationGoogle returns *PlatformApplication for Android GCM.

func (*SNS) Infof

func (svc *SNS) Infof(format string, v ...interface{})

Infof logging information.

func (*SNS) Publish

func (svc *SNS) Publish(arn string, msg string, options map[string]interface{}) error

Publish sends mobile notifications to the ARN (topic or endpoint).

func (*SNS) PublishAPNSByToken

func (svc *SNS) PublishAPNSByToken(token string, msg string, badge int) error

PublishAPNSByToken sends push message for iOS device by device token

func (*SNS) PublishByToken

func (svc *SNS) PublishByToken(device, token string, msg string, badge int) error

PublishByToken sends push message by device token

func (*SNS) PublishGCMByToken

func (svc *SNS) PublishGCMByToken(token string, msg string, badge int) error

PublishGCMByToken sends push message for Android device by device token

func (*SNS) RegisterEndpoint

func (svc *SNS) RegisterEndpoint(device, token string) (*PlatformEndpoint, error)

RegisterEndpoint creates endpoint(device) to platform application.

func (*SNS) RegisterEndpointWithUserData

func (svc *SNS) RegisterEndpointWithUserData(device, token, userData string) (*PlatformEndpoint, error)

RegisterEndpointWithUserData creates endpoint(device) and CustomUserData to platform application.

func (*SNS) SetAsProduction

func (svc *SNS) SetAsProduction()

SetAsProduction sets productiom mode flag.

func (*SNS) SetLogger

func (svc *SNS) SetLogger(logger log.Logger)

SetLogger sets logger.

type Topic

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

Topic is struct for Topic.

func NewTopic

func NewTopic(svc *SNS, arn, name string) *Topic

NewTopic returns initialized *Topic.

func (*Topic) Delete

func (t *Topic) Delete() error

Delete deltes the topic.

func (*Topic) Publish

func (t *Topic) Publish(msg string) error

Publish sends notification to the topic.

func (*Topic) Subscribe

func (t *Topic) Subscribe(endpointARN, protocol string) (subscriptionARN string, err error)

Subscribe operates `Subscribe` and returns `SubscriptionArn`.

Jump to

Keyboard shortcuts

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