fcm

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AndroidConfig

type AndroidConfig struct {
	CollapseKey           string                 `json:"collapse_key,omitempty"`
	Priority              AndroidMessagePriority `json:"priority,omitempty"`
	TTL                   string                 `json:"ttl,omitempty"`
	RestrictedPackageName string                 `json:"restricted_package_name,omitempty"`
	Data                  map[string]string      `json:"data,omitempty"`
	Notification          *AndroidNotification   `json:"Notification,omitempty"`
	FcmOptions            AndroidFcmOptions      `json:"fcm_options,omitempty"`
}

AndroidConfig format https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidconfig

func (AndroidConfig) MarshalEasyJSON

func (v AndroidConfig) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AndroidConfig) MarshalJSON

func (v AndroidConfig) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AndroidConfig) UnmarshalEasyJSON

func (v *AndroidConfig) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AndroidConfig) UnmarshalJSON

func (v *AndroidConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AndroidFcmOptions

type AndroidFcmOptions struct {
	AnalyticsLabel string `json:"analytics_label"`
}

AndroidFcmOptions format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidfcmoptions

func (AndroidFcmOptions) MarshalEasyJSON

func (v AndroidFcmOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AndroidFcmOptions) MarshalJSON

func (v AndroidFcmOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AndroidFcmOptions) UnmarshalEasyJSON

func (v *AndroidFcmOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AndroidFcmOptions) UnmarshalJSON

func (v *AndroidFcmOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AndroidMessagePriority

type AndroidMessagePriority string

AndroidMessagePriority values: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidmessagepriority

const (
	AndroidMessagePriorityNormal AndroidMessagePriority = "NORMAL"
	AndroidMessagePriorityHigh   AndroidMessagePriority = "HIGH"
)

type AndroidNotification

type AndroidNotification struct {
	Title        string   `json:"title,omitempty"`
	Body         string   `json:"body,omitempty"`
	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"`
	ChannelID    string   `json:"channel_id,omitempty"`
	Image        string   `json:"image,omitempty"`
}

AndroidNotification format https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification

func (AndroidNotification) MarshalEasyJSON

func (v AndroidNotification) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AndroidNotification) MarshalJSON

func (v AndroidNotification) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AndroidNotification) UnmarshalEasyJSON

func (v *AndroidNotification) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AndroidNotification) UnmarshalJSON

func (v *AndroidNotification) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ApnsConfig

type ApnsConfig struct {
	Headers    map[string]string      `json:"headers,omitempty"`
	Payload    map[string]interface{} `json:"payload,omitempty"`
	FcmOptions *ApnsFcmOptions        `json:"fcm_options,omitempty"`
}

ApnsConfig format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#apnsconfig

func (ApnsConfig) MarshalEasyJSON

func (v ApnsConfig) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ApnsConfig) MarshalJSON

func (v ApnsConfig) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ApnsConfig) UnmarshalEasyJSON

func (v *ApnsConfig) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ApnsConfig) UnmarshalJSON

func (v *ApnsConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ApnsFcmOptions

type ApnsFcmOptions struct {
	AnalyticsLabel string `json:"analytics_label,omitempty"`
	Image          string `json:"image,omitempty"`
}

ApnsFcmOptions foramt: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#apnsfcmoptions

func (ApnsFcmOptions) MarshalEasyJSON

func (v ApnsFcmOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ApnsFcmOptions) MarshalJSON

func (v ApnsFcmOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ApnsFcmOptions) UnmarshalEasyJSON

func (v *ApnsFcmOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ApnsFcmOptions) UnmarshalJSON

func (v *ApnsFcmOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(serviceAccount []byte, isSandbox bool, retries int, timeout time.Duration) (*Client, error)

func (*Client) Sandbox

func (c *Client) Sandbox() bool

func (*Client) Send

func (c *Client) Send(ctx context.Context, message *Message) (retval *Response, err error)

type ErrorCode

type ErrorCode string

ErrorCode values https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode

const (
	ErrorCodeUnregistered    ErrorCode = "UNREGISTERED"
	ErrorCodeUnavailable     ErrorCode = "UNAVAILABLE"
	ErrorCodeInternal        ErrorCode = "INTERNAL"
	ErrorCodeUnspecified     ErrorCode = "UNSPECIFIED_ERROR"
	ErrorCodeInvalidArgument ErrorCode = "INVALID_ARGUMENT"
)

type FcmOptions

type FcmOptions struct {
	AnalyticsLabel string `json:"analytics_label,omitempty"`
}

FcmOptions format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#fcmoptions

func (FcmOptions) MarshalEasyJSON

func (v FcmOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (FcmOptions) MarshalJSON

func (v FcmOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*FcmOptions) UnmarshalEasyJSON

func (v *FcmOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*FcmOptions) UnmarshalJSON

func (v *FcmOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Message

type Message struct {
	Name         string            `json:"name,omitempty"`
	Token        string            `json:"token,omitempty"`
	Topic        string            `json:"topic,omitempty"`
	Condition    string            `json:"condition,omitempty"`
	Data         map[string]string `json:"data,omitempty"`
	Notification *Notification     `json:"notification,omitempty"`
	Android      *AndroidConfig    `json:"android,omitempty"`
	Webpush      *WebpushConfig    `json:"webpush,omitempty"`
	Apns         *ApnsConfig       `json:"apns,omitempty"`
	FcmOptions   *FcmOptions       `json:"fcm_options,omitempty"`
}

Message format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message

func (Message) MarshalEasyJSON

func (v Message) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Message) MarshalJSON

func (v Message) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Message) SetToken

func (m *Message) SetToken(token string)

func (*Message) ShouldIgnore added in v1.0.2

func (m *Message) ShouldIgnore() bool

func (*Message) UnmarshalEasyJSON

func (v *Message) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Message) UnmarshalJSON

func (v *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Notification

type Notification struct {
	Title string `json:"title,omitempty"`
	Body  string `json:"body,omitempty"`
	Image string `json:"image,omitempty"`
}

Notification format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification

func (Notification) MarshalEasyJSON

func (v Notification) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Notification) MarshalJSON

func (v Notification) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Notification) UnmarshalEasyJSON

func (v *Notification) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Notification) UnmarshalJSON

func (v *Notification) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Request added in v1.0.4

type Request struct {
	ValidateOnly bool            `json:"validate_only,omitempty"`
	Message      json.RawMessage `json:"message"`
}

func (Request) MarshalEasyJSON added in v1.0.4

func (v Request) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Request) MarshalJSON added in v1.0.4

func (v Request) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Request) UnmarshalEasyJSON added in v1.0.4

func (v *Request) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Request) UnmarshalJSON added in v1.0.4

func (v *Request) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Response

type Response struct {
	Name       string     `json:"name,omitempty"`
	StatusCode int        `json:"-"`
	Error      *SendError `json:"error,omitempty"`
}

Response format: error example:

{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"\": Root element must be a message.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "description": "Invalid JSON payload received. Unknown name \"\": Root element must be a message."
          }
        ]
      }
    ]
  }
}

success example:

{
  "name": "projects/<project-id>/messages/0:1564476468894369%30820c6b30820c6b"
}

func (Response) MarshalEasyJSON

func (v Response) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Response) MarshalJSON

func (v Response) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Response) Ok

func (r *Response) Ok() bool

Ok returns true if notification success send

func (*Response) UnmarshalEasyJSON

func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Response) UnmarshalJSON

func (v *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SendError

type SendError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`

	// error status:
	// https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
	Status ErrorCode `json:"status"`

	Details json.RawMessage `json:"details"`
}

SendError format: error response example:

{
  "code": 400,
  "message": "Invalid JSON payload received. Unknown name \"\": Root element must be a message.",
  "status": "INVALID_ARGUMENT",
  "details": [
    {
    "@type": "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations": [
      {
      "description": "Invalid JSON payload received. Unknown name \"\": Root element must be a message."
      }
    ]
    }
  ]
}

func (SendError) Error

func (e SendError) Error() string

Error is 'error' interface implementation

func (SendError) MarshalEasyJSON

func (v SendError) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SendError) MarshalJSON

func (v SendError) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SendError) UnmarshalEasyJSON

func (v *SendError) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SendError) UnmarshalJSON

func (v *SendError) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type WebpushConfig

type WebpushConfig struct {
	Headers      map[string]string      `json:"headers,omitempty"`
	Data         map[string]string      `json:"data,omitempty"`
	Notification map[string]interface{} `json:"notification,omitempty"`
	FcmOptions   *WebpushFcmOptions     `json:"fcm_options,omitempty"`
}

WebpushConfig format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushconfig

func (WebpushConfig) MarshalEasyJSON

func (v WebpushConfig) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WebpushConfig) MarshalJSON

func (v WebpushConfig) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WebpushConfig) UnmarshalEasyJSON

func (v *WebpushConfig) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WebpushConfig) UnmarshalJSON

func (v *WebpushConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type WebpushFcmOptions

type WebpushFcmOptions struct {
	Link string `json:"link,omitempty"`
}

WebpushFcmOptions format: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions

func (WebpushFcmOptions) MarshalEasyJSON

func (v WebpushFcmOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WebpushFcmOptions) MarshalJSON

func (v WebpushFcmOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WebpushFcmOptions) UnmarshalEasyJSON

func (v *WebpushFcmOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WebpushFcmOptions) UnmarshalJSON

func (v *WebpushFcmOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL