Documentation ¶
Index ¶
- Constants
- type ApnsBatchRequest
- type ApnsBatchResponse
- type BatchRequest
- type BatchResponse
- type FcmClient
- func (this *FcmClient) ApnsBatchImportRequest(apnsReq *ApnsBatchRequest) (*ApnsBatchResponse, error)
- func (this *FcmClient) AppendDevices(list []string) *FcmClient
- func (this *FcmClient) BatchSubscribeToTopic(tokens []string, topic string) (*BatchResponse, error)
- func (this *FcmClient) BatchUnsubscribeFromTopic(tokens []string, topic string) (*BatchResponse, error)
- func (this *FcmClient) GetInfo(withDetails bool, instanceIdToken string) (*InstanceIdInfoResponse, error)
- func (this *FcmClient) NewFcmMsgTo(to string, body interface{}) *FcmClient
- func (this *FcmClient) NewFcmRegIdsMsg(list []string, body interface{}) *FcmClient
- func (this *FcmClient) NewFcmTopicMsg(to string, body map[string]string) *FcmClient
- func (this *FcmClient) Send() (*FcmResponseStatus, error)
- func (this *FcmClient) SetCollapseKey(val string) *FcmClient
- func (this *FcmClient) SetCondition(condition string) *FcmClient
- func (this *FcmClient) SetContentAvailable(isContentAvailable bool) *FcmClient
- func (this *FcmClient) SetDelayWhileIdle(isDelayWhileIdle bool) *FcmClient
- func (this *FcmClient) SetDryRun(drun bool) *FcmClient
- func (this *FcmClient) SetMsgData(body interface{}) *FcmClient
- func (this *FcmClient) SetMutableContent(mc bool) *FcmClient
- func (this *FcmClient) SetNotificationPayload(payload *NotificationPayload) *FcmClient
- func (this *FcmClient) SetPriority(p string) *FcmClient
- func (this *FcmClient) SetRestrictedPackageName(pkg string) *FcmClient
- func (this *FcmClient) SetTimeToLive(ttl int) *FcmClient
- func (this *FcmClient) SubscribeToTopic(instanceIdToken string, topic string) (*SubscribeResponse, error)
- type FcmMsg
- type FcmResponseStatus
- type InstanceIdInfoResponse
- type NotificationPayload
- type SubscribeResponse
Constants ¶
const ( // MAX_TTL the default ttl for a notification MAX_TTL = 2419200 // Priority_HIGH notification priority Priority_HIGH = "high" // Priority_NORMAL notification priority Priority_NORMAL = "normal" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApnsBatchRequest ¶
type ApnsBatchRequest struct { App string `json:"application,omitempty"` Sandbox bool `json:"sandbox,omitempty"` ApnsTokens []string `json:"apns_tokens,omitempty"` }
ApnsBatchRequest apns import request
func (*ApnsBatchRequest) ToByte ¶
func (this *ApnsBatchRequest) ToByte() ([]byte, error)
ToByte converts ApnsBatchRequest to a byte
type ApnsBatchResponse ¶
type ApnsBatchResponse struct { Results []map[string]string `json:"results,omitempty"` Error string `json:"error,omitempty"` Status string StatusCode int }
ApnsBatchResponse apns import response
func (*ApnsBatchResponse) PrintResults ¶
func (this *ApnsBatchResponse) PrintResults()
PrintResults prints ApnsBatchResponse, for faster debugging
type BatchRequest ¶
type BatchRequest struct { To string `json:"to,omitempty"` RegTokens []string `json:"registration_tokens,omitempty"` }
BatchRequest add/remove request
type BatchResponse ¶
type BatchResponse struct { Error string `json:"error,omitempty"` Results []map[string]string `json:"results,omitempty"` Status string StatusCode int }
BatchResponse add/remove response
func (*BatchResponse) PrintResults ¶
func (this *BatchResponse) PrintResults()
PrintResults prints BatchResponse, for faster debugging
type FcmClient ¶
FcmClient stores the key and the Message (FcmMsg)
func NewFcmClient ¶
NewFcmClient init and create fcm client
func (*FcmClient) ApnsBatchImportRequest ¶
func (this *FcmClient) ApnsBatchImportRequest(apnsReq *ApnsBatchRequest) (*ApnsBatchResponse, error)
ApnsBatchImportRequest apns import requst
func (*FcmClient) AppendDevices ¶
AppendDevices adds more devices/tokens to the Fcm request
func (*FcmClient) BatchSubscribeToTopic ¶
func (this *FcmClient) BatchSubscribeToTopic(tokens []string, topic string) (*BatchResponse, error)
BatchSubscribeToTopic subscribes (many) devices/tokens to a given topic
func (*FcmClient) BatchUnsubscribeFromTopic ¶
func (this *FcmClient) BatchUnsubscribeFromTopic(tokens []string, topic string) (*BatchResponse, error)
BatchUnsubscribeFromTopic unsubscribes (many) devices/tokens from a given topic
func (*FcmClient) GetInfo ¶
func (this *FcmClient) GetInfo(withDetails bool, instanceIdToken string) (*InstanceIdInfoResponse, error)
GetInfo gets the instance id info
func (*FcmClient) NewFcmMsgTo ¶
NewFcmMsgTo sets the targeted token/topic and the data payload
func (*FcmClient) NewFcmRegIdsMsg ¶
NewFcmRegIdsMsg gets a list of devices with data payload
func (*FcmClient) NewFcmTopicMsg ¶
NewFcmTopicMsg sets the targeted token/topic and the data payload
func (*FcmClient) SetCollapseKey ¶
SetCollapseKey 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 (see delay_while_idle).
func (*FcmClient) SetCondition ¶
SetCondition to set a logical expression of conditions that determine the message target
func (*FcmClient) SetContentAvailable ¶
SetContentAvailable 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. On Android, data messages wake the app by default. On Chrome, currently not supported.
func (*FcmClient) SetDelayWhileIdle ¶
SetDelayWhileIdle When this parameter is set to true, it indicates that the message should not be sent until the device becomes active. The default value is false.
func (*FcmClient) SetDryRun ¶
SetDryRun This parameter, when set to true, allows developers to test a request without actually sending a message. The default value is false
func (*FcmClient) SetMsgData ¶
SetMsgData sets data payload
func (*FcmClient) SetMutableContent ¶
SetMutableContent 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. This parameter will be ignored for Android and web.
func (*FcmClient) SetNotificationPayload ¶
func (this *FcmClient) SetNotificationPayload(payload *NotificationPayload) *FcmClient
SetNotificationPayload sets the notification payload based on the specs https://firebase.google.com/docs/cloud-messaging/http-server-ref
func (*FcmClient) SetPriority ¶
SetPriority Sets the priority of the message. Priority_HIGH or Priority_NORMAL
func (*FcmClient) SetRestrictedPackageName ¶
SetRestrictedPackageName This parameter specifies the package name of the application where the registration tokens must match in order to receive the message.
func (*FcmClient) SetTimeToLive ¶
SetTimeToLive 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. For more information, see https://firebase.google.com/docs/cloud-messaging/concept-options#ttl
func (*FcmClient) SubscribeToTopic ¶
func (this *FcmClient) SubscribeToTopic(instanceIdToken string, topic string) (*SubscribeResponse, error)
SubscribeToTopic subscribes a single device/token to a topic
type FcmMsg ¶
type FcmMsg struct { Data interface{} `json:"data,omitempty"` To string `json:"to,omitempty"` RegistrationIds []string `json:"registration_ids,omitempty"` CollapseKey string `json:"collapse_key,omitempty"` Priority string `json:"priority,omitempty"` Notification NotificationPayload `json:"notification,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` RestrictedPackageName string `json:"restricted_package_name,omitempty"` DryRun bool `json:"dry_run,omitempty"` Condition string `json:"condition,omitempty"` MutableContent bool `json:"mutable_content,omitempty"` }
FcmMsg represents fcm request message
type FcmResponseStatus ¶
type FcmResponseStatus struct { Ok bool StatusCode int MulticastId int64 `json:"multicast_id"` Success int `json:"success"` Fail int `json:"failure"` Canonical_ids int `json:"canonical_ids"` Results []map[string]string `json:"results,omitempty"` MsgId int64 `json:"message_id,omitempty"` Err string `json:"error,omitempty"` RetryAfter string }
FcmMsg represents fcm response message - (tokens and topics)
func (*FcmResponseStatus) GetRetryAfterTime ¶
func (this *FcmResponseStatus) GetRetryAfterTime() (t time.Duration, e error)
GetRetryAfterTime converts the retrey after response header to a time.Duration
func (*FcmResponseStatus) IsTimeout ¶
func (this *FcmResponseStatus) IsTimeout() bool
IsTimeout check whether the response timeout based on http response status code and if any error is retryable
func (*FcmResponseStatus) PrintResults ¶
func (this *FcmResponseStatus) PrintResults()
PrintResults prints the FcmResponseStatus results for fast using and debugging
type InstanceIdInfoResponse ¶
type InstanceIdInfoResponse struct { Application string `json:"application,omitempty"` AuthorizedEntity string `json:"authorizedEntity,omitempty"` ApplicationVersion string `json:"applicationVersion,omitempty"` AppSigner string `json:"appSigner,omitempty"` AttestStatus string `json:"attestStatus,omitempty"` Platform string `json:"platform,omitempty"` ConnectionType string `json:"connectionType,omitempty"` ConnectDate string `json:"connectDate,omitempty"` Error string `json:"error,omitempty"` Rel map[string]map[string]map[string]string `json:"rel,omitempty"` }
InstanceIdInfoResponse response for instance id info request
func (*InstanceIdInfoResponse) PrintResults ¶
func (this *InstanceIdInfoResponse) PrintResults()
PrintResults prints InstanceIdInfoResponse, for faster debugging
type NotificationPayload ¶
type NotificationPayload 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"` 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"` AndroidChannelID string `json:"android_channel_id,omitempty"` }
NotificationPayload notification message payload
type SubscribeResponse ¶
type SubscribeResponse struct { Error string `json:"error,omitempty"` Status string StatusCode int }
SubscribeResponse response for single topic subscribtion
func (*SubscribeResponse) PrintResults ¶
func (this *SubscribeResponse) PrintResults()
PrintResults prints SubscribeResponse, for faster debugging