push

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2015 License: MIT Imports: 10 Imported by: 49

Documentation

Overview

Package push sends notifications over HTTP/2 to Apple's Push Notification Service.

Index

Constants

View Source
const (
	Sandbox = "https://api.sandbox.push.apple.com"
	Live    = "https://api.push.apple.com"
)

Apple host locations.

Variables

View Source
var (
	ErrBadDeviceToken = errors.New("bad device token")
	ErrForbidden      = errors.New("forbidden, check your certificate")
)

Service error responses.

Functions

func NewClient

func NewClient(cert tls.Certificate) *http.Client

NewClient sets up an HTTPS client for a certificate. If you need to do something custom, you can always specify your own http.Client for Service.

Types

type Headers

type Headers struct {
	// ID for the notification. Apple generates one if ommitted.
	// This should be a UUID with 32 lowercase hexadecimal digits.
	// TODO: use a UUID type.
	ID string

	// Apple will retry delivery until this time. The default behavior only tries once.
	Expiration time.Time

	// Allow Apple to group messages to together to reduce power consumption.
	// By default messages are sent immediately.
	LowPriority bool

	// Topic is the bundle ID for your app.
	Topic string
}

Headers sent with a push to control the notification (optional)

type Service

type Service struct {
	Client *http.Client
	Host   string
}

Service is the Apple Push Notification Service that you send notifications to.

func (*Service) Push

func (s *Service) Push(deviceToken string, headers *Headers, payload json.Marshaler) error

Push notification to APN service after performing serialization.

func (*Service) PushBytes

func (s *Service) PushBytes(deviceToken string, headers *Headers, payload []byte) error

PushBytes notification to APN service.

Jump to

Keyboard shortcuts

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