TsgcWSAPIServer_WebPushMethods › BroadcastNotification

BroadcastNotification Method

Sends the same notification to every subscription currently held in the internal Subscriptions list.

Overloads

Overload 1

Syntax

procedure BroadcastNotification(const aMessage : TsgcWebPushMessage);

Parameters

NameTypeDescription
aMessageconst TsgcWebPushMessageStructured notification (Title/Body/Icon/Url) serialized once via AsJSON and reused for each subscription.

Remarks

Iterates the thread-safe Subscriptions list under a lock and calls SendNotification for each entry. If a send fails, OnWebPushSendNotificationException fires and, when Remove is returned True (the default), the subscription is automatically dropped from the list — ideal for cleaning up 404/410 responses from the push service.

Example

var
  oMessage: TsgcWebPushMessage;
begin
  oMessage := TsgcWebPushMessage.Create;
  try
    oMessage.Title := 'eSeGeCe Notification';
    oMessage.Body  := 'New version released!!!';
    oMessage.Icon  := 'https://www.esegece.com/images/esegece_logo_small.png';
    oMessage.Url   := 'https://www.esegece.com';
    sgcWSAPIServer_WebPush1.BroadcastNotification(oMessage);
  finally
    oMessage.Free;
  end;
end;

Overload 2

Syntax

procedure BroadcastNotification(const aMessage: string);

Parameters

NameTypeDescription
aMessageconst stringRaw payload (usually JSON) delivered verbatim to every subscriber after per-subscription encryption.

Remarks

Convenience overload when the broadcast payload is already serialized. You can add or remove subscriptions manually through Subscriptions.AddSubscription/Subscriptions.RemoveSubscription if you manage persistence yourself.

Example

sgcWSAPIServer_WebPush1.BroadcastNotification(
  '{"title":"Heads up","body":"Server restarting in 5 min"}');

Back to Methods