Documentation
¶
Overview ¶
Package webpush supports Generic Event Delivery Using HTTP Push.
Generic Event Delivery Using HTTP Push https://www.rfc-editor.org/rfc/rfc8030.html
Message Encryption for Web Push https://www.rfc-editor.org/rfc/rfc8291.html
Voluntary Application Server Identification (VAPID) for Web Push https://www.rfc-editor.org/rfc/rfc8292
Encrypted Content-Encoding for HTTP: https://www.rfc-editor.org/rfc/rfc8188
MDN Push API: https://developer.mozilla.org/en-US/docs/Web/API/Push_API
Apple Push Notification Documentation: https://developer.apple.com/documentation/usernotifications/sending-web-push-notifications-in-web-apps-and-browsers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateVAPIDKey ¶
GenerateVAPIDKey will create a private VAPID key in Base64 Raw URL Encoding. Generate a key and store it in your configuration. Use ParseVAPIDKey on application startup to parse it for use in the Config.
func ParseVAPIDKey ¶
func ParseVAPIDKey(privateKey string) (*ecdsa.PrivateKey, error)
ParseVAPIDKey parses a private key encoded in Base64 Raw URL Encoding. Use GenerateVAPIDKey to generate a key for use in your application.
Types ¶
type Config ¶
type Config struct {
Client *http.Client // Required http.Client.
VAPIDKey *ecdsa.PrivateKey // Required VAPID Private Key.
Subscriber string // Required Subscriber, https URL or mailto: email address.
TTL time.Duration // Required TTL on the endpoint POST request (rounded to seconds).
Topic string // Optional Topic to collapse pending messages.
Urgency Urgency // Optional Urgency for message priority.
RecordSize int // Optional custom RecordSize, defaults to 4096 per spec.
VAPIDExpiration time.Time // Optional custom expiration for VAPID JWT token (defaults to now + 12 hours).
}
Config specifies required and optional aspects for sending a Push Notification.
type Subscription ¶
Subscription represents a PushSubscription from the User Agent.
type Urgency ¶
type Urgency string
Urgency directly impacts battery life.
https://www.rfc-editor.org/rfc/rfc8030.html#section-5.3
const ( // UrgencyVeryLow targets "On power and Wi-Fi". UrgencyVeryLow Urgency = "very-low" // UrgencyLow targets "On either power or Wi-Fi". UrgencyLow Urgency = "low" // UrgencyNormal targets "On neither power nor Wi-Fi". UrgencyNormal Urgency = "normal" // UrgencyHigh targets any state including "Low battery". UrgencyHigh Urgency = "high" )