Documentation ¶
Index ¶
Constants ¶
const ( StatusOK = "ok" StatusError = "error" PriorityDefault = "default" PriorityNormal = "normal" PriorityHigh = "high" )
Variables ¶
var ( ErrDeviceNotRegistered = newPushError("DeviceNotRegistered") ErrMessageTooBig = newPushError("MessageTooBig") ErrMessageRateExceeded = newPushError("MessageRateExceeded") ErrMismatchSenderId = newPushError("MismatchSenderId") ErrInvalidCredentials = newPushError("InvalidCredentials") ErrTooManyRequests = newPushError("TOO_MANY_REQUESTS") ErrPushTooManyExperienceIDs = newPushError("PUSH_TOO_MANY_EXPERIENCE_IDS") ErrPushTooManyNotifications = newPushError("PUSH_TOO_MANY_NOTIFICATIONS") ErrPushTooManyReceipts = newPushError("PUSH_TOO_MANY_RECEIPTS") ErrPushTokenNotFound = newPushError("Push token not found for DBID") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient creates a new Expo push client with the specified API URL and access token. accessToken may be an empty string if the organization's push settings don't require an access token.
func (*Client) GetReceipts ¶
func (*Client) SendMessages ¶
func (c *Client) SendMessages(ctx context.Context, messages []PushMessage) ([]PushTicket, error)
type GetReceiptsRequest ¶
type GetReceiptsRequest struct {
TicketIDs []string `json:"ids"`
}
type GetReceiptsResponse ¶
type GetReceiptsResponse struct { Data map[string]PushReceipt `json:"data"` Errors []RequestError `json:"errors"` }
func (*GetReceiptsResponse) GetError ¶
func (r *GetReceiptsResponse) GetError() error
type PushMessage ¶
type PushMessage struct { // An Expo push token or an array of Expo push tokens specifying the recipient(s) of this message. To string `json:"to"` // A JSON object delivered to your app. It may be up to about 4KiB; the total notification payload //sent to Apple and Google must be at most 4KiB or else you will get a "Message Too Big" error. Data map[string]any `json:"data,omitempty"` // The title to display in the notification. Often displayed above the notification body Title string `json:"title,omitempty"` // The message to display in the notification. Body string `json:"body"` // Time to Live: the number of seconds for which the message may be kept around for redelivery if it // hasn't been delivered yet. Defaults to undefined in order to use the respective defaults of each // provider (0 for iOS/APNs and 2419200 (4 weeks) for Android/FCM). TTL int `json:"ttl,omitempty"` // Timestamp since the Unix epoch specifying when the message expires. // Same effect as ttl (ttl takes precedence over expiration). Expiration int64 `json:"expiration,omitempty"` // The delivery priority of the message. Specify "default" or omit this field to use the default // priority on each platform ("normal" on Android and "high" on iOS). Priority string `json:"priority,omitempty"` // iOS only. The subtitle to display in the notification below the title. Subtitle string `json:"subtitle,omitempty"` // iOS only. Play a sound when the recipient receives this notification. Specify "default" to play //the device's default notification sound, or omit this field to play no sound. Custom sounds are not supported. Sound string `json:"sound,omitempty"` // iOS only. Number to display in the badge on the app icon. Specify zero to clear the badge. Badge int `json:"badge,omitempty"` // Android only. ID of the Notification Channel through which to display this notification. If an ID is // specified but the corresponding channel does not exist on the device (i.e. has not yet been created // by your app), the notification will not be displayed to the user. ChannelID string `json:"channelId,omitempty"` // ID of the notification category that this notification is associated with. Must be on at least SDK 41 or bare workflow. // Find out more about notification categories here: // https://docs.expo.dev/versions/latest/sdk/notifications#managing-notification-categories-interactive-notifications CategoryID string `json:"categoryId,omitempty"` // iOS only. Specifies whether this notification can be intercepted by the client app. In Expo Go, this // defaults to true, and if you change that to false, you may experience issues. In standalone and bare apps, // this defaults to false. // See: https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications MutableContent bool `json:"mutableContent,omitempty"` // contains filtered or unexported fields }
PushMessage is an Expo-formatted push message. See: https://docs.expo.dev/push-notifications/sending-notifications/#message-request-format
type PushNotificationHandler ¶
type PushNotificationHandler struct {
// contains filtered or unexported fields
}
Batching pattern adapted from dataloaden (https://github.com/vektah/dataloaden)
func (*PushNotificationHandler) CheckPushTickets ¶
func (h *PushNotificationHandler) CheckPushTickets() error
type PushReceipt ¶
type PushReceipt struct { Status string `json:"status"` Message string `json:"message"` Details map[string]any `json:"details"` }
func (PushReceipt) GetError ¶
func (t PushReceipt) GetError(ctx context.Context) error
GetError gets the error for the receipt, if any. Returns nil if no error. See: https://docs.expo.dev/push-notifications/sending-notifications#push-receipt-errors
type PushTicket ¶
type PushTicket struct { TicketID string `json:"id"` Status string `json:"status"` Message string `json:"message"` Details map[string]any `json:"details"` }
func (PushTicket) GetError ¶
func (t PushTicket) GetError(ctx context.Context) error
GetError gets the error for the ticket, if any. Returns nil if no error. See: https://docs.expo.dev/push-notifications/sending-notifications/#push-ticket-errors
type RequestError ¶
type SendMessagesResponse ¶
type SendMessagesResponse struct { Data []PushTicket `json:"data"` Errors []RequestError `json:"errors"` }
func (*SendMessagesResponse) GetError ¶
func (r *SendMessagesResponse) GetError() error