Documentation ¶
Index ¶
- type Client
- func (c *Client) SendMessage() (rm *HTTPResponse, err error)
- func (c *Client) SendMessageWithHTTPClient(ctx context.Context) (rm *HTTPResponse, err error)
- func (c *Client) SetCollapseKey(collapseKey string)
- func (c *Client) SetCondition(condition string)
- func (c *Client) SetContentAvailable(contentAvailable bool)
- func (c *Client) SetData(body interface{})
- func (c *Client) SetDryRun(dryRun bool)
- func (c *Client) SetMutableContent(mutableContent bool)
- func (c *Client) SetNotification(np NotificationPayload)
- func (c *Client) SetPriority(priority string)
- func (c *Client) SetRegistrationIds(registrationIds []string)
- func (c *Client) SetRestrictedPackageName(restrictedPackageName string)
- func (c *Client) SetServerKey(serverKey string)
- func (c *Client) SetTimeToLive(timeToLive int)
- func (c *Client) SetTo(to string)
- type HTTPMessage
- type HTTPResponse
- type HTTPResponseResult
- type NotificationPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ServerKey string Message HTTPMessage }
Client stores the key and the Message
func (*Client) SendMessage ¶
func (c *Client) SendMessage() (rm *HTTPResponse, err error)
SendMessage to firebase
func (*Client) SendMessageWithHTTPClient ¶
func (c *Client) SendMessageWithHTTPClient(ctx context.Context) (rm *HTTPResponse, err error)
SendMessageWithHTTPClient to firebase
func (*Client) SetCollapseKey ¶
SetCollapseKey identifies a group of messages
func (*Client) SetCondition ¶
SetCondition sets a logical expression of conditions that determine the message target
func (*Client) SetContentAvailable ¶
SetContentAvailable use this field to represent content-available in the APNs payload
func (*Client) SetDryRun ¶
SetDryRun allows developers to test a request without actually sending a message
func (*Client) SetMutableContent ¶
SetMutableContent use this field to represent mutable-content in the APNs payload
func (*Client) SetNotification ¶
func (c *Client) SetNotification(np NotificationPayload)
SetNotification sets the notification payload
func (*Client) SetPriority ¶
SetPriority sets the priority of the message
func (*Client) SetRegistrationIds ¶
SetRegistrationIds sets the recipient of a multicast message
func (*Client) SetRestrictedPackageName ¶
SetRestrictedPackageName sets the package name of the application where the registration tokens must match in order to receive the message
func (*Client) SetServerKey ¶
SetServerKey sets the server key
func (*Client) SetTimeToLive ¶
SetTimeToLive sets how long (in seconds) the message should be kept in FCM storage if the device is offline.
type HTTPMessage ¶
type HTTPMessage struct { To string `json:"to,omitempty"` // This parameter specifies the recipient of a message. RegistrationIds []string `json:"registration_ids,omitempty"` // This parameter specifies the recipient of a multicast message, a message sent to more than one registration token. Condition string `json:"condition,omitempty"` // This parameter specifies a logical expression of conditions that determine the message target. NotificationKey string `json:"notification_key,omitempty"` // This parameter is deprecated. Instead, use to to specify message recipients. CollapseKey string `json:"collapse_key,omitempty"` // This parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can be collapsed, so that only the last message gets sent when delivery can be resumed. This is intended to avoid sending too many of the same messages when the device comes back online or becomes active. Priority string `json:"priority,omitempty"` // Sets the priority of the message. Valid values are "normal" and "high." On iOS, these correspond to APNs priorities 5 and 10. ContentAvailable bool `json:"content_available,omitempty"` // On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported. MutableContent bool `json:"mutable_content,omitempty"` // Currently for iOS 10+ devices only. On iOS, use this field to represent mutable-content in the APNs payload. When a notification is sent and this is set to true, the content of the notification can be modified before it is displayed, using a Notification Service app extension. DelayWhileIdle bool `json:"delay_while_idle,omitempty"` // This parameter is deprecated. TimeToLive int `json:"time_to_live,omitempty"` // This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. RestrictedPackageName string `json:"restricted_package_name,omitempty"` // This parameter specifies the package name of the application where the registration tokens must match in order to receive the message. DryRun bool `json:"dry_run,omitempty"` // This parameter, when set to true, allows developers to test a request without actually sending a message. Data interface{} `json:"data,omitempty"` // This parameter specifies the custom key-value pairs of the message's payload. Notification NotificationPayload `json:"notification,omitempty"` // This parameter specifies the predefined, user-visible key-value pairs of the notification payload. }
HTTPMessage -> Downstream HTTP messages
type HTTPResponse ¶
type HTTPResponse struct { StatusCode int MulticastID int64 `json:"multicast_id"` Success int `json:"success"` Failure int `json:"failure"` CanonicalIds int `json:"canonical_ids"` Results []HTTPResponseResult `json:"results,omitempty"` MessageID int64 `json:"message_id,omitempty"` Error string `json:"error,omitempty"` }
HTTPResponse -> Downstream HTTP message response
type HTTPResponseResult ¶
type HTTPResponseResult struct { MessageID string `json:"message_id"` RegistrationID int `json:"registration_id"` Error string `json:"error,omitempty"` }
HTTPResponseResult -> Downstream HTTP message response result
type NotificationPayload ¶
type NotificationPayload struct { Title string `json:"title,omitempty"` // The notification's title.(iOS,Android,Web) Body string `json:"body,omitempty"` // The notification's body text.(iOS,Android,Web) AndroidChannelID string `json:"android_channel_id,omitempty"` // The notification's channel id (new in Android O).(Android) Icon string `json:"icon,omitempty"` // The notification's icon.(Android,Web) Sound string `json:"sound,omitempty"` // The sound to play when the device receives the notification.(iOS,Android) Badge string `json:"badge,omitempty"` // The value of the badge on the home screen app icon.(iOS) Tag string `json:"tag,omitempty"` // Identifier used to replace existing notifications in the notification drawer.(Android) Color string `json:"color,omitempty"` // The notification's icon color, expressed in #rrggbb format.(Android) ClickAction string `json:"click_action,omitempty"` // The action associated with a user click on the notification.(iOS,Android,Web) Subtitle string `json:"subtitle,omitempty"` // The notification's subtitle.(iOS) BodyLocKey string `json:"body_loc_key,omitempty"` // The key to the body string in the app's string resources to use to localize the body text to the user's current localization.(iOS,Android) BodyLocArgs string `json:"body_loc_args,omitempty"` // Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization.(iOS,Android) TitleLocKey string `json:"title_loc_key,omitempty"` // The key to the title string in the app's string resources to use to localize the title text to the user's current localization.(iOS,Android) TitleLocArgs string `json:"title_loc_args,omitempty"` // Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization.(iOS,Android) }
NotificationPayload -> Notification payload support