Documentation ¶
Overview ¶
Package apns implements the Apple Push Notification System (APNS) binary interface.
Index ¶
- Variables
- func Dial(cer *tls.Certificate, host string, delay bool) (net.Conn, error)
- func DialAPN(cer *tls.Certificate, env Environment, delay bool) (net.Conn, error)
- func DialFeedback(cer *tls.Certificate, env Environment) (net.Conn, error)
- func LoadPem(pemBlock []byte) (cert tls.Certificate, err error)
- func LoadPemFile(pemFile string) (cert tls.Certificate, err error)
- type Environment
- type Packet
- type PushNotification
Constants ¶
This section is empty.
Variables ¶
var UnknwonCommandErr = errors.New("Unknown command ID.")
UnknwonCommandErr error is used when APN data is encountered with a command that is unknown.
Functions ¶
func Dial ¶
Dial will connect to an APNs server provided in the host parameter. Unless you plan on using a non-standard APNs server (like a mock server) then it's preferable to use DialAPN or DialFeedback.
func DialAPN ¶
func DialAPN(cer *tls.Certificate, env Environment, delay bool) (net.Conn, error)
DialAPN will create a TCP connection to Apple's APNs server using the certificate provided. The delay parameter tells the network stack to use Nagle's algorithm to batch data in TCP packets.
func DialFeedback ¶
func DialFeedback(cer *tls.Certificate, env Environment) (net.Conn, error)
DialFeedback will create a TCP connection to Apple's feedback service.
func LoadPem ¶
func LoadPem(pemBlock []byte) (cert tls.Certificate, err error)
LoadPem is similar to tls.X509KeyPair found in tls.go except that this function reads all blocks from the same file.
func LoadPemFile ¶
func LoadPemFile(pemFile string) (cert tls.Certificate, err error)
LoadPemFile reads a combined certificate+key pem file into memory.
Types ¶
type Environment ¶
type Environment int8
Environment represents an APNs production or sandbox environment configuration for connections.
From the Local and Push Notification Programming Guide:
The binary interface of the production environment is available through gateway.push.apple.com, port 2195; the binary interface of the sandbox (development) environment is available through gateway.sandbox.push.apple.com, port 2195. You may establish multiple, parallel connections to the same gateway or to multiple gateway instances.
const ( DISTRIBUTION Environment = iota SANDBOX Environment = iota )
type Packet ¶
Packet represents the various data formats that may be encountered when communicating with APNs.
type PushNotification ¶
type PushNotification interface { PushNotification() ReadFrom(r io.Reader) error WriteTo(w io.Writer) error String() string }
Notification represents a specific set of APNs packets which are used for delivering push notifications.
func MakeNotification ¶
func MakeNotification(data []byte) (pn PushNotification)