client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Username string
	Password string
}

type BatchResult

type BatchResult struct {
	Code      int    `json:"code"`
	Message   string `json:"message,omitempty"`
	DeviceKey string `json:"device_key"`
}

type Client

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

func New

func New(serverURL string, timeout int, auth *AuthConfig) *Client

func (*Client) CheckDevice

func (c *Client) CheckDevice(deviceKey string) error

CheckDevice checks if a device is registered.

func (*Client) Info

func (c *Client) Info() (*ServerInfo, error)

Info retrieves server information.

func (*Client) Ping

func (c *Client) Ping() error

Ping checks server connectivity.

func (*Client) Push

func (c *Client) Push(req *PushRequest) (*CommonResp, error)

Push sends a notification to a single device.

func (*Client) PushBatch

func (c *Client) PushBatch(req *PushRequest) (*CommonResp, error)

PushBatch sends notifications to multiple devices.

func (*Client) Register

func (c *Client) Register(deviceKey, deviceToken string) (*RegisterResp, error)

Register registers a device. Returns the device key.

type CommonResp

type CommonResp struct {
	Code      int    `json:"code"`
	Message   string `json:"message"`
	Data      any    `json:"data,omitempty"`
	Timestamp int64  `json:"timestamp"`
}

type PushRequest

type PushRequest struct {
	DeviceKey  string   `json:"device_key,omitempty"`
	DeviceKeys []string `json:"device_keys,omitempty"`
	Title      string   `json:"title,omitempty"`
	Subtitle   string   `json:"subtitle,omitempty"`
	Body       string   `json:"body,omitempty"`
	Sound      string   `json:"sound,omitempty"`
	Level      string   `json:"level,omitempty"`
	Volume     int      `json:"volume,omitempty"`
	Badge      int      `json:"badge,omitempty"`
	Icon       string   `json:"icon,omitempty"`
	Group      string   `json:"group,omitempty"`
	URL        string   `json:"url,omitempty"`
	Copy       string   `json:"copy,omitempty"`
	IsArchive  string   `json:"isArchive,omitempty"`
	Call       string   `json:"call,omitempty"`
	ID         string   `json:"id,omitempty"`
	Image      string   `json:"image,omitempty"`
	Ciphertext string   `json:"ciphertext,omitempty"`
	Action     string   `json:"action,omitempty"`
}

type RegisterResp

type RegisterResp struct {
	Key         string `json:"key"`
	DeviceKey   string `json:"device_key"`
	DeviceToken string `json:"device_token"`
}

type ServerInfo

type ServerInfo struct {
	Version string `json:"version"`
	Build   string `json:"build"`
	Arch    string `json:"arch"`
	Commit  string `json:"commit"`
	Devices int    `json:"devices"`
}

Jump to

Keyboard shortcuts

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