Documentation
¶
Overview ¶
Package push is the push domain: the message a caller hands to courier.SendPush, its checks, token hashing and the FCM HTTP v1 message it becomes. Everything FCM takes is reachable: the common fields are modeled, and the raw android, apns, webpush and fcm_options blocks are merged over them for whatever is not.
Index ¶
Constants ¶
View Source
const ( MaxPayloadBytes = 4096 MaxTTLSeconds = 28 * 24 * 3600 )
Limits of FCM.
Variables ¶
View Source
var ( ErrTarget = errors.New("push: exactly one of token, topic or condition is required") ErrToken = errors.New("push: invalid device token") ErrTopic = errors.New("push: invalid topic") ErrCondition = errors.New("push: invalid condition") ErrDataKey = errors.New("push: reserved data key") ErrPriority = errors.New("push: priority is high or normal") ErrTTL = errors.New("push: ttl_seconds is 0 to 2419200 (28 days)") ErrTooBig = errors.New("push: message exceeds 4096 bytes of payload") )
Errors of Validate; every one is final.
Functions ¶
Types ¶
type Message ¶
type Message struct {
Channel string `json:"channel,omitempty" schemapb:"description=Push channel of the installation, else the default"`
Token string `json:"token,omitempty" schemapb:"description=Device registration token"`
Topic string `json:"topic,omitempty" schemapb:"description=Topic, instead of a token"`
Condition string `json:"condition,omitempty" schemapb:"description=Topic condition, instead of a token"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Image string `json:"image,omitempty" schemapb:"description=Image URL"`
Data map[string]string `json:"data,omitempty" schemapb:"description=Key-value data for the app"`
Priority string `json:"priority,omitempty" schemapb:"description=high or normal"`
TTLSeconds int64 `json:"ttl_seconds,omitempty" schemapb:"description=How long FCM keeps it for an offline device"`
CollapseKey string `json:"collapse_key,omitempty" schemapb:"description=A newer message with the key replaces it"`
// Raw FCM blocks, merged over what the fields above produce: any
// field FCM takes (mutable-content, content-available, apns-push-type,
// direct_boot_ok, notification options...). See the FCM HTTP v1
// Message reference.
Android map[string]any `json:"android,omitempty" schemapb:"description=Raw AndroidConfig"`
APNS map[string]any `json:"apns,omitempty" schemapb:"description=Raw ApnsConfig"`
Webpush map[string]any `json:"webpush,omitempty" schemapb:"description=Raw WebpushConfig"`
FCMOptions map[string]any `json:"fcm_options,omitempty" schemapb:"description=Raw FcmOptions"`
// ValidateOnly: FCM checks the message and delivers nothing.
ValidateOnly bool `json:"validate_only,omitempty" schemapb:"description=Check the message with FCM, deliver nothing"`
}
Message is one push: to a device token, a topic or a condition.
Click to show internal directories.
Click to hide internal directories.