Documentation
¶
Overview ¶
----------------------------------------------------------------*\
- @author Ly Nam <lyquocnam@live.com>
- @copyright 2019 Viet Tran <viettranx@gmail.com>
- @license Apache-2.0
- @description Plugin to work with Firebase Cloud Messaging *----------------------------------------------------------------
Index ¶
- Variables
- func New(name string) *fcmClient
- type FirebaseCloudMessaging
- type Notification
- type Opt
- func WithAction(action string) Opt
- func WithBadge(badge string) Opt
- func WithBody(body string) Opt
- func WithCollapseKey(collapseKey string) Opt
- func WithColor(color string) Opt
- func WithIcon(icon string) Opt
- func WithPayload(payload map[string]string) Opt
- func WithSound(sound string) Opt
- func WithTag(tag string) Opt
- type Response
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotifyNotSuccess = errors.New("can't send notification") ErrNotificationEmpty = errors.New("notification can't not be empty") ErrMissingRegistration = createCustomError("MissingRegistration") ErrInvalidRegistration = createCustomError("InvalidRegistration") ErrNotRegistered = createCustomError("NotRegistered") ErrInvalidPackageName = createCustomError("InvalidPackageName") ErrMismatchSenderId = createCustomError("MismatchSenderId") ErrInvalidParameters = createCustomError("InvalidParameters") ErrMessageTooBig = createCustomError("MessageTooBig") ErrInvalidDataKey = createCustomError("InvalidDataKey") ErrInvalidTtl = createCustomError("InvalidTtl") ErrInternalServerError = createCustomError("InternalServerError") ErrDeviceMessageRateExceeded = createCustomError("DeviceMessageRateExceeded") ErrTopicsMessageRateExceeded = createCustomError("TopicsMessageRateExceeded") ErrInvalidApnsCredential = createCustomError("ErrInvalidApnsCredential") )
Functions ¶
Types ¶
type FirebaseCloudMessaging ¶
type FirebaseCloudMessaging interface {
// Send notification to a topic
// @topic: /topics/chat
SendToTopic(ctx context.Context, topic string, notification *Notification) (*Response, error)
// Send notification to a device
// @deviceId: fCZ4_yRHP5U:APA91bHJTY...
SendToDevice(ctx context.Context, deviceId string, notification *Notification) (*Response, error)
// Send notification to many devices
// @deviceIds: []string{ "fCZ4_yRHP5U:APA91bHJTY..." }
SendToDevices(ctx context.Context, deviceIds []string, notification *Notification) (*Response, error)
// Show the response result of notification, use for debugging
ShowPrintResult(show bool)
// Get API Key
APIKey() string
}
type Notification ¶
type Notification struct {
Payload map[string]string `json:"-"`
CollapseKey *string `json:"-"`
TimeToLive int `json:"-"`
DelayWhileIdle bool `json:"-"`
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"`
}
func NewNotification ¶
func NewNotification(title string, opts ...Opt) *Notification
Click to show internal directories.
Click to hide internal directories.