Documentation
¶
Index ¶
Constants ¶
const ( PriorityHigh = "high" PriorityNormal = "normal" )
const ( ErrorMissingRegistration = "MissingRegistration" ErrorInvalidRegistration = "InvalidRegistration" ErrorNotRegistered = "NotRegistered" ErrorInvalidPackageName = "InvalidPackageName" ErrorMismatchSenderId = "MismatchSenderId" ErrorMessageTooBig = "MessageTooBig" ErrorInvalidDataKey = "InvalidDataKey" ErrorInvalidTtl = "InvalidTtl" ErrorInternalServerError = "InternalServerError" ErrorDeviceMessageRateExceeded = "DeviceMessageRateExceeded" ErrorTopicsMessageRateExceeded = "TopicsMessageRateExceeded" )
Error messages
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient returns an FCM client. The client is expected to be long-lived. It maintains an internal pool of HTTP connections. Multiple sumultaneous Send requests can be issued on the same client.
func (*Client) GetRetryAfter ¶
GetRetryAfter returns the number fo seconds to wait before retrying Send in case the previous Send has failed.
func (*Client) PostHttp ¶
func (c *Client) PostHttp(msg *HttpMessage) (<-chan *HttpResponse, error)
PostHttp is a non-blocking version of Send. Not implemented yet.
func (*Client) SendHttp ¶
func (c *Client) SendHttp(msg *HttpMessage) (*HttpResponse, error)
SendHttp is a blocking call to send an HTTP message to FCM server. Multiple Send requests can be issued simultaneously on the same Client.
type HttpMessage ¶
type HttpMessage struct { To string `json:"to,omitempty"` RegistrationIds []string `json:"registration_ids,omitempty"` Condition string `json:"condition,omitempty"` CollapseKey string `json:"collapse_key,omitempty"` Priority string `json:"priority,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` TimeToLive *uint `json:"time_to_live,omitempty"` RestrictedPackageName string `json:"restricted_package_name,omitempty"` DryRun bool `json:"dry_run,omitempty"` Data interface{} `json:"data,omitempty"` Notification *Notification `json:"notification,omitempty"` }
HttpMessage is an FCM HTTP request message
type HttpResponse ¶
type HttpResponse struct { MulticastId int `json:"multicast_id"` Success int `json:"success"` Fail int `json:"failure"` CanonicalIds int `json:"canonical_ids"` Results []Result `json:"results,omitempty"` }
HttpResponse is an FCM response message
type Notification ¶
type Notification struct { Title string `json:"title,omitempty"` Body string `json:"body,omitempty"` Sound string `json:"sound,omitempty"` ClickAction string `json:"click_action,omitempty"` BodyLocKey string `json:"body_loc_key,omitempty"` BodyLocArgs string `json:"body_loc_args,omitempty"` TitleLocKey string `json:"title_loc_key,omitempty"` TitleLocArgs string `json:"title_loc_args,omitempty"` // Android only Icon string `json:"icon,omitempty"` Tag string `json:"tag,omitempty"` Color string `json:"color,omitempty"` // iOS only Badge string `json:"badge,omitempty"` }
Notification notification message structure