firebase

package
v0.0.0-...-40b5090 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathToRegistrationTokens          = "/users/%s/fcmRegistrationTokens"               // %s - user's id
	PathToRegistrationTokenDeprecated = "/users/%s/fcmRegistrationTokens/%s/deprecated" // %s - user's id, %s - number of token
	PathToRegistrationTokenRotated    = "/users/%s/fcmRegistrationTokens/%s/rotated"    // %s - user's id, %s - number of token
	PathToRegistrationToken           = "/users/%s/fcmRegistrationTokens/%s"            // %s - user's id, %s - number of token
)
View Source
const (
	// Firebase Cloud Messaging messages
	FCMTokenActive               = "FCM registration token is active"
	FCMTokenUnregisteredError    = "FCM registration token was unregistered"
	FCMTokenInvalidArgumentError = "FCM registration token is invalid"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func InitClient

func InitClient(databaseURL string, credentialsJSON []byte) (*Client, error)

func (*Client) DeleteUserRT

func (c *Client) DeleteUserRT(uid string, id string) error

DeleteUserRT function deletes the Firebase Cloud Messaging Registration Token entry from the database.

func (*Client) DetectInvalidToken

func (c *Client) DetectInvalidToken(token string) error

DetectInvalidToken function determines if a Firebase Cloud Messaging Registration Token is still valid by sending a message in dry run mode.

func (*Client) GetAllUsers

func (c *Client) GetAllUsers() ([]User, error)

func (*Client) GetUserRTs

func (c *Client) GetUserRTs(uid string) (map[string]RegistrationToken, error)

GetUserRTs function returns a map which contains the Firebase Cloud Messaging Registration Tokens that belong to a user along with other metadata. The keys are UUIDs generated when the tokens are added to the database.

func (*Client) SetUserRTDeprecated

func (c *Client) SetUserRTDeprecated(uid string, id string, deprecated bool) error

SetUserRTDeprecated function sets the deprecated field of a user's Firebase Cloud Messaging Registration Token. By setting this to true, it marks the token for rotation which will be done by application on the user's smartphone.

func (*Client) SetUserRTRotated

func (c *Client) SetUserRTRotated(uid string, id string, rotated bool) error

SetUserRTRotated function sets the rotated field of a user's Firebase Cloud Messaging Registration Token.

type RegistrationToken

type RegistrationToken struct {
	CreatedOn  int64  `json:"createdOn"`
	Deprecated bool   `json:"deprecated"`
	Rotated    bool   `json:"rotated"`
	Token      string `json:"token"`
}

type User

type User struct {
	UID string
}

Jump to

Keyboard shortcuts

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