Documentation
¶
Overview ¶
Golang client library for Firebase Cloud Messaging. It uses Firebase Cloud Messaging HTTP protocol: https://firebase.google.com/docs/cloud-messaging/http-server-ref.
Index ¶
- type Client
- func (c *Client) GetDeviceInfo(token string) (*DeviceInfoResponse, error)
- func (c *Client) GetUser(token string) (*User, error)
- func (c *Client) Send(message Message) (*MessageResponse, error)
- func (c *Client) SubscribeToTopic(tokens []string, topic string) error
- func (c *Client) UnsubscribeFromTopic(tokens []string, topic string) error
- type DeviceInfoResponse
- type LookupUserResponse
- type Message
- type MessageResponse
- type MessageResponseResult
- type Notification
- type ProviderInfo
- type RelDate
- type Relationship
- type TopicMessageResponse
- type TopicSubscribe
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // API key ApiKey string // Server key // Firebase console > Project Settings > Cloud Messaging > Server key ServerKey string }
func (*Client) GetDeviceInfo ¶
func (c *Client) GetDeviceInfo(token string) (*DeviceInfoResponse, error)
Get information about app instances
func (*Client) Send ¶
func (c *Client) Send(message Message) (*MessageResponse, error)
Send sends a Message to Firebase Cloud Messaging.
The Message must specify exactly one of Token, Topic and Condition fields. FCM will customize the message for each target platform based on the arguments specified in the Message. Use Legacy HTTP Server Protocol
https://firebase.google.com/docs/cloud-messaging/http-server-ref
func (*Client) SubscribeToTopic ¶
SubscribeToTopic subscribes a list of registration tokens to a topic. The tokens list must not be empty, and have at most 1000 tokens.
type DeviceInfoResponse ¶
type DeviceInfoResponse struct { ApplicationVersion string `json:"applicationVersion,omitempty"` ConnectDate string `json:"connectDate,omitempty"` Application string `json:"application,omitempty"` Scope string `json:"scope,omitempty"` AuthorizedEntity string `json:"authorizedEntity,omitempty"` ConnectionType string `json:"connectionType,omitempty"` Platform string `json:"platform,omitempty"` Rel Relationship `json:"rel,omitempty"` }
type LookupUserResponse ¶ added in v1.1.0
type Message ¶
type Message struct { // Targets To string `json:"to,omitempty"` RegistrationIds []string `json:"registration_ids,omitempty"` Condition string `json:"condition,omitempty"` // Options CollapseKey string `json:"collapse_key,omitempty"` Priority string `json:"priority,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` RestrictedPackageName string `json:"restricted_package_name,omitempty"` DryRun bool `json:"dry_run,omitempty"` // Payload Data map[string]string `json:"data,omitempty"` Notification Notification `json:"notification,omitempty"` }
Downstream HTTP messages (JSON)
https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json
type MessageResponse ¶
type MessageResponse struct { // Message MulticastId int64 `bson:"multicast_id,omitempty" json:"multicast_id,omitempty"` Success int `bson:"success,omitempty" json:"success,omitempty"` Failure int `bson:"failure,omitempty" json:"failure,omitempty"` Results []MessageResponseResult `bson:"results,omitempty" json:"results,omitempty"` // Topic TopicMessageResponse }
Downstream HTTP message response body (JSON). Include topic message HTTP response body.
type MessageResponseResult ¶
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"` /// iOS only Subtitle string `json:"subtitle,omitempty"` Badge string `json:"badge,omitempty"` /// Android only AndroidChannelId string `json:"android_channel_id,omitempty"` Icon string `json:"icon,omitempty"` Tag string `json:"tag,omitempty"` Color string `json:"color,omitempty"` }
type ProviderInfo ¶ added in v1.1.2
type Relationship ¶
type TopicMessageResponse ¶
type TopicMessageResponse struct { MessageId int64 `bson:"message_id,omitempty" json:"message_id,omitempty"` Error string `bson:"error,omitempty" json:"error,omitempty"` }
Topic message HTTP response body (JSON)
type TopicSubscribe ¶
type User ¶ added in v1.1.0
type User struct { LocalId string `json:"localId,omitempty"` PhoneNumber string `json:"phoneNumber,omitempty"` Email string `json:"email,omitempty"` EmailVerified bool `json:"emailVerified,omitempty"` DisplayName string `json:"displayName,omitempty"` PhotoUrl string `json:"photoUrl,omitempty"` ValidSince string `json:"validSince,omitempty"` Disabled string `json:"disabled,omitempty"` LastLoginAt string `json:"lastLoginAt,omitempty"` CreatedAt string `json:"createdAt,omitempty"` ProviderUserInfo []ProviderInfo `json:"providerUserInfo,omitempty"` }