WebPush Server

Send WebPush notifications from a Delphi server. Built-in VAPID signing, AES128GCM payload encryption and the subscription-management endpoints required by the spec.

TsgcWSAPIServer_WebPush

WebPush relying-party component — register subscriptions, encrypt payloads (RFC 8291), sign requests with VAPID (RFC 8292), POST to the user's push endpoint.

Component class

TsgcWSAPIServer_WebPush

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Enterprise

Drop the server, send a notification

Configure the VAPID key pair, attach the embedded TsgcWebPush_Client (or use it directly), then call SendNotification with the subscription endpoint and payload.

uses
  sgcWebSocket, sgcWebSocket_Server_APIs;

var
  Server: TsgcWebSocketHTTPServer;
  WebPush: TsgcWSAPIServer_WebPush;
begin
  Server := TsgcWebSocketHTTPServer.Create(nil);
  Server.Port := 8443;
  Server.SSL  := True;

  WebPush := TsgcWSAPIServer_WebPush.Create(nil);
  WebPush.Server := Server;
  WebPush.VAPID.Subject := 'mailto:admin@example.com';
  WebPush.VAPID.PrivateKey.LoadFromFile('vapid-priv.pem');
  WebPush.VAPID.PublicKey.LoadFromFile ('vapid-pub.pem');

  Server.Active := True;

  // later, when you have a subscription record
  WebPush.SendNotification(
    'https://fcm.googleapis.com/wp/...', // endpoint
    'p256dh-public-key', // from PushSubscription.getKey(p256dh)
    'auth-secret', // from PushSubscription.getKey(auth)
    '{"title":"Hello","body":"Notification body"}');
end;

What's inside

A complete WebPush relay — manages subscriptions and sends VAPID-signed AES128GCM-encrypted notifications.

Subscription endpoints

Hosts the POST /webpush/subscribe + DELETE /webpush/unsubscribe contract on the embedded HTTP server, so browser clients can register their PushSubscription with you.

VAPID signing

Per RFC 8292 the component signs each push with an ES256 JWT and includes the VAPID public key in the Crypto-Key header. Subject contact (mailto:) is configurable.

aes128gcm encryption

Implements RFC 8291 message-encryption: derives the shared secret with ECDH against the user's p256dh, computes HKDF-derived keys, encrypts with AES128GCM.

Payload size handling

Pads payloads up to the recommended max so message length cannot be inferred from the ciphertext — matches what browser push services expect.

Embedded client

TsgcWebPush_Client is a sibling that just sends notifications without hosting subscriptions — useful if your subscriptions live in a separate service.

TTL / urgency

Standard TTL, Urgency and Topic headers are exposed as method parameters, letting you tell the push service how long to retain undelivered notifications.

Specifications & references

Authoritative sources for the protocol this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Online Help — WebPush Full property, method and event reference for this component.
Demo Project — Demos\20.HTTP_Protocol\11.WebPush_Notifications Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.

Ready to Send WebPush Notifications?

Download the free trial and add VAPID-signed WebPush to your Delphi server.