[−][src]Crate web_push
Web Push
A library for creating and sending push notifications to a web browser. For content payload encryption it uses the Encrypted Content-Encoding for HTTP, draft 3. The client is asynchronious and uses Tokio with futures.
Example
let endpoint = "https://updates.push.services.mozilla.com/wpush/v1/..."; let p256dh = base64::decode_config("key_from_browser_as_base64", URL_SAFE)?; let auth = base64::decode_config("auth_from_browser_as_base64", URL_SAFE)?; let subscription_info = SubscriptionInfo::new( endpoint, "BLMbF9ffKBiWQLCKvTHb6LO8Nb6dcUh6TItC455vu2kElga6PQvUmaFyCdykxY2nOSSL3yKgfbmFLRTUaGv4yV8", "xS03Fi5ErfTNH_l9WHE9Ig" ); let mut builder = WebPushMessageBuilder::new(&subscription_info)?; let content = "Encrypted payload to be sent in the notification".as_bytes(); builder.set_payload(ContentEncoding::AesGcm, content); let client = WebPushClient::new(); let response = client.send(builder.build()?).await?; println!("Got response: {:?}", response);
Structs
SubscriptionInfo | Client info for sending the notification. Maps the values from browser's subscription info JSON data. |
SubscriptionKeys | Encryption keys from the client. |
VapidSignature | A struct representing a VAPID signature. Should be generated using the VapidSignatureBuilder. |
VapidSignatureBuilder | A VAPID signature builder for generating an optional signature to the request. With a given signature, one can pass the registration to Google's FCM service. And prevent unauthorized notifications to be sent to the client. |
WebPushClient | An async client for sending the notification payload. |
WebPushMessage | Everything needed to send a push notification to the user. |
WebPushMessageBuilder | The main class for creating a notification payload. |
WebPushPayload | The push content payload, already in an encrypted form. |
Enums
ContentEncoding | |
WebPushError |