Documentation ¶
Index ¶
Constants ¶
View Source
const ( ApplicationJSON = "application/json" LimitApnsTokenByteSize = 100 // Payload byte size. )
View Source
const ( // HTTP2 client timeout HTTP2ClientTimeout = time.Second * 10 )
View Source
const Provider = "apns"
Variables ¶
View Source
var ClientTransport = func(cert tls.Certificate) *http.Transport { return &http.Transport{ TLSClientConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, }, } }
Functions ¶
func StartAPNSMockServer ¶
func StartAPNSMockServer(cert, key string)
StartAPNSMockServer starts HTTP/2 server for mock
Types ¶
type APS ¶
type APS struct { Alert interface{} `json:"alert,omitempty"` Badge int `json:"badge,omitempty"` Sound string `json:"sound,omitempty"` ContentAvailable int `json:"content-available,omitempty"` Category string `json:"category,omitempty"` ThreadID string `json:"thread-id,omitempty"` MutableContent int `json:"mutable-content,omitempty"` TargetContentID string `json:"target-content-id,omitempty"` }
APS is a part of Payload
type Alert ¶
type Alert struct { Title string `json:"title,omitempty"` Body string `json:"body,omitempty"` TitleLocKey string `json:"title-loc-key,omitempty"` TitleLocArgs []string `json:"title-loc-args,omitempty"` ActionLocKey string `json:"action-loc-key,omitempty"` LocKey string `json:"loc-key,omitempty"` LocArgs []string `json:"loc-args,omitempty"` LaunchImage string `json:"launch-image,omitempty"` }
Alert is a part of APS
type Client ¶
type Client struct { Host string // contains filtered or unexported fields }
Client is apns client
func (*Client) NewRequest ¶
NewRequest creates request for apns
type ErrorResponse ¶
type ErrorResponseCode ¶
type ErrorResponseCode int
ErrorResponseCode shows error message of responses from apns
const ( PayloadEmpty ErrorResponseCode = iota PayloadTooLarge BadTopic TopicDisallowed BadExpirationDate BadPriority MissingDeviceToken BadDeviceToken DeviceTokenNotForTopic Unregistered DuplicateHeaders BadCertificateEnvironment BadCertificate Forbidden BadPath MethodNotAllowed TooManyRequests IdleTimeout Shutdown InternalServerError MissingTopic BadCollapseId BadMessageId ExpiredProviderToken InvalidProviderToken MissingProviderToken TooManyProviderTokenUpdates )
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html HTTP/2 Response from APNs Table 8-6 ErrorMessage const
func (ErrorResponseCode) String ¶
func (i ErrorResponseCode) String() string
type Header ¶
type Header struct { ApnsID string `json:"apns-id,omitempty"` ApnsExpiration string `json:"apns-expiration,omitempty"` ApnsPriority string `json:"apns-priority,omitempty"` ApnsTopic string `json:"apns-topic,omitempty"` ApnsPushType string `json:"apns-push-type,omitempty"` }
Header for apns request
type Notification ¶
type Notification struct { Header Header `json:"header,omitempty"` Token string `json:"token"` Payload Payload `json:"payload"` }
Request for a http2 client
type Payload ¶
Payload is Notification Payload
func (Payload) MarshalJSON ¶
MarshalJSON for Payload struct.
func (*Payload) UnmarshalJSON ¶
UnmarshalJSON for Payload struct.
type Result ¶
type Result struct { APNsID string `json:"apns-id"` StatusCode int `json:"status"` Token string `json:"token"` Reason string `json:"reason"` }
Response from apns
func (Result) ExtraValue ¶
func (Result) MarshalJSON ¶
func (Result) RecipientIdentifier ¶
Click to show internal directories.
Click to hide internal directories.