fcmv1

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFCMEndpoint = "https://fcm.googleapis.com/v1/projects"
	Scope              = "https://www.googleapis.com/auth/firebase.messaging"
	ClientTimeout      = time.Second * 10
)

fcm v1 Client const variables

View Source
const (
	InvalidArgument = "INVALID_ARGUMENT"
	Unregistered    = "UNREGISTERED"
	NotFound        = "NOT_FOUND"
	Internal        = "INTERNAL"
	Unavailable     = "UNAVAILABLE"
	QuotaExceeded   = "QUOTA_EXCEEDED"
)

Error const variables

View Source
const MaxBulkRequests = 500

MaxBulkRequests represens max count of request payloads in a request body.

View Source
const Provider = "fcmv1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Client is FCM v1 client

func NewClient

func NewClient(tokenSource oauth2.TokenSource, projectID string, endpoint string, timeout time.Duration) (*Client, error)

NewClient establishes a http connection with fcm v1

func (*Client) NewRequest

func (c *Client) NewRequest(p Payload) (*http.Request, error)

NewRequest creates request for fcm

func (*Client) Send

func (c *Client) Send(p Payload) ([]Result, error)

Send sends notifications to fcm

type Detail

type Detail struct {
	Type      string `json:"@type"`
	ErrorCode string `json:"errorCode,omitempty"`
}

type Error

type Error struct {
	StatusCode int
	Reason     string
}

func NewError

func NewError(s int, r string) Error

func (Error) Error

func (e Error) Error() string

type FCMError

type FCMError struct {
	Status  string   `json:"status"`
	Message string   `json:"message,omitempty"`
	Details []Detail `json:"details,omitempty"`
}

type FCMErrorResponseCode

type FCMErrorResponseCode int

type Payload

type Payload struct {
	Message messaging.Message `json:"message"`
}

Payload for fcm v1

type ResponseBody

type ResponseBody struct {
	Name  string    `json:"name,omitempty"`
	Error *FCMError `json:"error,omitempty"`
}

ResponseBody fcm response body

type Result

type Result struct {
	StatusCode int       `json:"status,omitempty"`
	Token      string    `json:"token,omitempty"`
	Error      *FCMError `json:"error,omitempty"`
}

Result is the status of a processed FCMResponse

func (Result) Err

func (r Result) Err() error

func (Result) ExtraKeys

func (r Result) ExtraKeys() []string

func (Result) ExtraValue

func (r Result) ExtraValue(key string) string

func (Result) MarshalJSON

func (r Result) MarshalJSON() ([]byte, error)

func (Result) Provider

func (r Result) Provider() string

func (Result) RecipientIdentifier

func (r Result) RecipientIdentifier() string

func (Result) Status

func (r Result) Status() int

Jump to

Keyboard shortcuts

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