Documentation ¶
Overview ¶
Package gcm provides send and receive GCM functionality.
Index ¶
- Constants
- Variables
- func NewFcmClient(serviceAccountFileContent string, ctx context.Context) (*fcmClient, error)
- type Data
- type ErrorResponse
- type FcmAndroidConfig
- type FcmAndroidNotification
- type FcmData
- type FcmHttpMessage
- type FcmMessageBody
- type FcmNotification
- type FcmSendHttpResponse
- type HttpMessage
- type HttpResponse
- type InstanceInformationResponse
- type Notification
- type Platform
- type Result
- type ServiceAccount
Constants ¶
View Source
const ( BaseURL = "https://fcm.googleapis.com/v1" InstanceIdApiUrl = "https://iid.googleapis.com/iid/info" FirebaseRequestScope = "https://www.googleapis.com/auth/firebase.messaging" DefaultContentType = "application/json" )
View Source
const ( CCSAck = "ack" CCSNack = "nack" CCSControl = "control" CCSReceipt = "receipt" )
Variables ¶
Functions ¶
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type FcmAndroidConfig ¶
type FcmAndroidConfig struct { CollapseKey string `json:"collapse_key"` Priority string `json:"priority,omitempty"` TimeToLive *string `json:"ttl,omitempty"` RestrictedPackageName string `json:"restricted_package_name,omitempty"` Notification *FcmAndroidNotification `json:"notification"` }
type FcmAndroidNotification ¶
type FcmAndroidNotification struct { Icon string `json:"icon,omitempty"` Color string `json:"color,omitempty"` Sound string `json:"sound,omitempty"` Tag string `json:"tag,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"` Ticker string `json:"ticker,omitempty"` Sticky bool `json:"sticky,omitempty"` LocalOnly bool `json:"local_only,omitempty"` NotificationCount int `json:"notification_count,omitempty"` ChannelId string `json:"channel_id,omitempty"` }
type FcmHttpMessage ¶
type FcmHttpMessage struct { Token string `json:"token,omitempty"` Notification *FcmNotification `json:"notification,omitempty"` Data FcmData `json:"data,omitempty"` Android *FcmAndroidConfig `json:"android"` }
type FcmMessageBody ¶
type FcmMessageBody struct {
Message *FcmHttpMessage `json:"message"`
}
type FcmNotification ¶
type FcmSendHttpResponse ¶
func SendPush ¶
func SendPush(ctx context.Context, serviceAccountConfig string, m FcmMessageBody) (*FcmSendHttpResponse, error)
type HttpMessage ¶
type HttpMessage struct { To string `json:"to,omitempty"` RegistrationIds []string `json:"registration_ids,omitempty"` CollapseKey string `json:"collapse_key,omitempty"` Priority string `json:"priority,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive *uint `json:"time_to_live,omitempty"` RestrictedPackageName string `json:"restricted_package_name,omitempty"` DryRun bool `json:"dry_run,omitempty"` Data Data `json:"data,omitempty"` Notification *Notification `json:"notification,omitempty"` }
A GCM Http message.
type HttpResponse ¶
type HttpResponse struct { Status int `json:"-"` MulticastId int `json:"multicast_id,omitempty"` Success uint `json:"success,omitempty"` Failure uint `json:"failure,omitempty"` CanonicalIds uint `json:"canonical_ids,omitempty"` Results []Result `json:"results,omitempty"` MessageId int `json:"message_id,omitempty"` Error string `json:"error,omitempty"` }
HttpResponse is the GCM connection server response to an HTTP downstream message request.
func SendHttp ¶
func SendHttp(ctx context.Context, platform Platform, apiKey string, m HttpMessage) (*HttpResponse, error)
Send a message using the HTTP GCM connection server.
type InstanceInformationResponse ¶
type InstanceInformationResponse struct {
AuthorizedEntity string `json:"authorizedEntity"`
}
type Notification ¶
type Notification struct { Title string `json:"title,omitempty"` Body string `json:"body,omitempty"` Icon string `json:"icon,omitempty"` Sound string `json:"sound,omitempty"` Badge string `json:"badge,omitempty"` Tag string `json:"tag,omitempty"` Color string `json:"color,omitempty"` ClickAction string `json:"click_action,omitempty"` AndroidChID string `json:"android_channel_id,omitempty"` BodyLocKey string `json:"body_loc_key,omitempty"` BodyLocArgs string `json:"body_loc_args,omitempty"` TitleLocArgs string `json:"title_loc_args,omitempty"` TitleLocKey string `json:"title_loc_key,omitempty"` }
The notification payload of a GCM message.
type Result ¶
type Result struct { MessageId string `json:"message_id,omitempty"` RegistrationId string `json:"registration_id,omitempty"` Error string `json:"error,omitempty"` }
Result represents the status of a processed Http message.
type ServiceAccount ¶
type ServiceAccount struct { ServiceAccountType string `json:"type"` ProjectId string `json:"project_id"` PrivateKeyId string `json:"private_key_id"` PrivateKey string `json:"private_key"` ClientEmail string `json:"client_email"` ClientId string `json:"client_id"` AuthUri string `json:"auth_uri"` TokenUri string `json:"token_uri"` }
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gcm-logger
Program gcm-logger logs and echoes as a GCM "server".
|
Program gcm-logger logs and echoes as a GCM "server". |
Click to show internal directories.
Click to hide internal directories.