Documentation ¶
Overview ¶
A Go package to interface with the Apple Push Notification Service
Features ¶
This library implements a few features that we couldn't find in any one library elsewhere:
Long Lived Clients - Apple's documentation say that you should hold a persistent connection open and not create new connections for every payload See: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW6) Use of New Protocol - Apple came out with v2 of their API with support for variable length payloads. This library uses that protocol. Robust Send Guarantees - APNS has asynchronous feedback on whether a push sent. That means that if you send pushes after a bad send, those pushes will be lost forever. Our library records the last N pushes, detects errors, and is able to resend the pushes that could have been lost. See: http://redth.codes/the-problem-with-apples-push-notification-ser/
Index ¶
Constants ¶
View Source
const ( ProductionGateway = "gateway.push.apple.com:2195" SandboxGateway = "gateway.sandbox.push.apple.com:2195" ProductionFeedbackGateway = "feedback.push.apple.com:2196" SandboxFeedbackGateway = "feedback.sandbox.push.apple.com:2196" )
View Source
const ( // Error strings based on the codes specified here: // https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW12 ErrProcessing = "Processing error" ErrMissingDeviceToken = "Missing device token" ErrMissingTopic = "Missing topic" ErrMissingPayload = "Missing payload" ErrInvalidTokenSize = "Invalid token size" ErrInvalidTopicSize = "Invalid topic size" ErrInvalidPayloadSize = "Invalid payload size" ErrInvalidToken = "Invalid token" ErrShutdown = "Shutdown" ErrUnknown = "None (unknown)" )
View Source
const ( PriorityImmediate = 10 PriorityPowerConserve = 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Conn *Conn FailedNotifs chan NotificationResult // contains filtered or unexported fields }
func NewClientWithCert ¶
func NewClientWithCert(gw string, cert tls.Certificate) Client
func NewClientWithFiles ¶
func (*Client) Send ¶
func (c *Client) Send(n Notification) error
type Conn ¶
Conn is a wrapper for the actual TLS connections made to Apple
func NewConnWithCert ¶
func NewConnWithCert(gw string, cert tls.Certificate) Conn
func NewConnWithFiles ¶
NewConnWithFiles creates a new Conn from certificate and key in the specified files
type Feedback ¶
type Feedback struct {
Conn *Conn
}
func NewFeedbackWithCert ¶
func NewFeedbackWithCert(gw string, cert tls.Certificate) Feedback
func NewFeedbackWithFiles ¶
func (Feedback) Receive ¶
func (f Feedback) Receive() <-chan FeedbackTuple
type FeedbackTuple ¶
type Notification ¶
type Notification struct { ID string DeviceToken string Identifier uint32 Expiration *time.Time Priority int Payload *Payload }
func NewNotification ¶
func NewNotification() Notification
func (Notification) ToBinary ¶
func (n Notification) ToBinary() ([]byte, error)
type NotificationResult ¶
type NotificationResult struct { Notif Notification Err Error }
type Payload ¶
type Payload struct { APS APS // contains filtered or unexported fields }
func NewPayload ¶
func NewPayload() *Payload
func (*Payload) MarshalJSON ¶
func (*Payload) SetCustomValue ¶
Click to show internal directories.
Click to hide internal directories.