TsgcWebPush_Client › Methods › SendNotification
Encrypts the payload with aes128gcm, VAPID-signs the request and POSTs it to the browser subscription endpoint.
public void SendNotification(TsgcHTTP_API_WebPush_PushSubscription aPushSubscription, string aText);
| Name | Type | Description |
|---|---|---|
aPushSubscription | const TsgcHTTP_API_WebPush_PushSubscription | Subscription record returned by the browser at registration time — carries Endpoint (the push service URL to POST to), PublicKey (user-agent P-256 public key, p256dh, Base64URL-encoded) and AuthSecret (16-byte auth secret, Base64URL-encoded) used to derive the per-message content encryption key. |
aText | const string | Clear-text payload to deliver to the browser (typically a JSON document interpreted by the Service Worker). The value is UTF-8 encoded and encrypted with aes128gcm before being sent; an empty string sends a notification with no payload. |
Single-call Web Push send (RFC 8030 + RFC 8291). The method validates that VAPID keys are configured and that aPushSubscription contains an Endpoint, PublicKey and AuthSecret; computes an ECDH shared secret against the user-agent public key; derives the content encryption key and nonce with HKDF; encrypts aText with aes128gcm; builds a VAPID JWT (ES256) signed with the PEM private key and adds it as the Authorization header; places the DER public key in the Crypto-Key header; and POSTs the binary ciphertext to the subscription endpoint. Missing keys raise an EsgcWebSocketException; the push service returns 201/202 on success, 404/410 when the subscription has expired and must be dropped, or 429 when throttling is applied.