Documentation ¶
Overview ¶
Package push sends notifications over HTTP/2 to Apple's Push Notification Service.
Index ¶
Constants ¶
View Source
const ( Development = "https://api.development.push.apple.com" Production = "https://api.push.apple.com" )
Apple host locations for configuring Service.
Variables ¶
View Source
var ( // These could be checked prior to sending the request to Apple. ErrPayloadEmpty = errors.New("PayloadEmpty") ErrPayloadTooLarge = errors.New("PayloadTooLarge") // Device token errors. ErrMissingDeviceToken = errors.New("MissingDeviceToken") ErrBadDeviceToken = errors.New("BadDeviceToken") ErrTooManyRequests = errors.New("TooManyRequests") // Header errors. ErrBadMessageID = errors.New("BadMessageID") ErrBadExpirationDate = errors.New("BadExpirationDate") ErrBadPriority = errors.New("BadPriority") ErrBadTopic = errors.New("BadTopic") // Certificate and topic errors. ErrBadCertificate = errors.New("BadCertificate") ErrBadCertificateEnvironment = errors.New("BadCertificateEnvironment") ErrForbidden = errors.New("Forbidden") ErrMissingTopic = errors.New("MissingTopic") ErrTopicDisallowed = errors.New("TopicDisallowed") ErrUnregistered = errors.New("Unregistered") ErrDeviceTokenNotForTopic = errors.New("DeviceTokenNotForTopic") // These errors should never happen when using Push. ErrDuplicateHeaders = errors.New("DuplicateHeaders") ErrBadPath = errors.New("BadPath") ErrMethodNotAllowed = errors.New("MethodNotAllowed") // Fatal server errors. ErrIdleTimeout = errors.New("IdleTimeout") ErrShutdown = errors.New("Shutdown") ErrInternalServerError = errors.New("InternalServerError") )
Service error responses.
Functions ¶
func IsDeviceTokenValid ¶ added in v0.3.0
IsDeviceTokenValid checks if s is a hexadecimal token of the correct length.
Types ¶
type Headers ¶
type Headers struct { // ID for the notification. Apple generates one if omitted. // 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 together to reduce power consumption. // By default messages are sent immediately. LowPriority bool }
Headers sent with a push to control the notification (optional)
type Service ¶
Service is the Apple Push Notification Service that you send notifications to.
func NewService ¶ added in v0.5.0
func NewService(host string, cert tls.Certificate) (*Service, error)
NewService sets up an HTTP/2 client for a certificate and extracts the Topic from the certificate. If you need to do something custom, you can always override the fields in Service, e.g. to specify your own http.Client.
Click to show internal directories.
Click to hide internal directories.