Documentation
¶
Index ¶
- Variables
- type Client
- func (c Client) FetchReceipt(ctx context.Context, ticket Ticket) *Receipt
- func (c Client) FetchReceipts(ctx context.Context, tickets []Ticket) (map[Ticket]Receipt, error)
- func (c Client) SendMessage(ctx context.Context, msg Message) (Ticket, error)
- func (c Client) SendMessages(ctx context.Context, msgs []Message) ([]Resp, error)
- type Data
- type Message
- type Priority
- type Promise
- type Receipt
- type Resp
- type Service
- type Ticket
- type Token
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDeviceNotRegistered = errors.New("device cannot receive push notifications anymore") ErrMessageTooBig = errors.New("total notification payload was too large") ErrMessageRateExceeded = errors.New("you are sending messages too frequently to the given device") ErrMismatchSenderID = errors.New("there is an issue with your FCM push credentials") ErrInvalidCredentials = errors.New("push notification credentials for your standalone app are invalid") ErrNoRecipients = errors.New("message has no recipients") ErrEmptyToken = errors.New("push token is empty") ErrTooManyMessages = errors.New("too many messages in a single request") ErrTooManyTickets = errors.New("too many tickets in a single request") ErrServerError = errors.New("server error") ErrTooManyRequests = errors.New("too many requests") ErrInvalidTicketCount = errors.New("the number of tickets doesn't match the number of messages") ErrBadRequest = errors.New("invalid request") ErrUnknown = errors.New("unknown error") ErrExpired = errors.New("timed out delivering message") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// The underlying client to use for HTTP requests.
Client http.Client
// The base API URL.
//
// Default: "https://exp.host"
BaseURL string
// The Bearer token to send in all HTTP requests.
AccessToken string
}
func (Client) FetchReceipt ¶
Check the delivery status for a push notification.
Returns nil if the message is not delivered yet. Returns the default Receipt (with Error == nil) is the message is successfully delivered.
func (Client) FetchReceipts ¶
func (Client) SendMessage ¶
type Message ¶
type Message struct {
// Expo push tokens specifying the recipient(s) of this message.
To []Token `json:"to"`
// The title to display in the notification.
//
// On iOS, this is displayed only on Apple Watch.
Title string `json:"title,omitempty"`
// The message to display in the notification.
Body string `json:"body"`
// A dict of extra data to pass inside of the push notification. The total notification payload must be at most 4096 bytes.
Data Data `json:"data,omitempty"`
// A sound to play when the recipient receives this notification.
//
// Specify "default" to play the device's default notification sound,
// or omit this field to play no sound.
Sound string `json:"sound,omitempty"`
// The number of seconds for which the message may be kept around for redelivery
// if it hasn't been delivered yet.
TTL int `json:"ttl,omitempty"`
// Delivery priority of the message.
Priority Priority `json:"priority,omitempty"`
// An integer representing the unread notification count.
//
// This currently only affects iOS. Specify 0 to clear the badge count.
Badge int `json:"badge,omitempty"`
// ID of the Notification Channel through which to display this notification on Android devices.
ChannelID string `json:"channelId,omitempty"`
}
type Promise ¶
type Promise struct {
// contains filtered or unexported fields
}
func (*Promise) Done ¶
func (p *Promise) Done() <-chan struct{}
Channel that will be closed when the Promise is done.
type Service ¶
type Service struct {
// The underlying client to use for sending requests.
Client *Client
// For how long to aggregate messages into chunks.
//
// In other words, it's the time since calling Send for the first message
// in a chunk to sending the whole chunk to the server.
//
// Default: 1 second.
SendChunk time.Duration
// For how long to aggregate tickets into chunks.
//
// Default: 1 second.
ResolveChunk time.Duration
// How often to re-check the status of a ticket.
//
// Default: 1 second.
ResolveInterval time.Duration
// contains filtered or unexported fields
}
The background service taking care of delivering notifications, batching requests, retries, resolving promises, etc.
func NewService ¶
func NewService() *Service
Click to show internal directories.
Click to hide internal directories.