TsgcWSAPIServer_WebPush › Methods › BroadcastNotification
Sends the same notification to every subscription currently held in the internal Subscriptions list.
procedure BroadcastNotification(const aMessage : TsgcWebPushMessage);
| Name | Type | Description |
|---|---|---|
aMessage | const TsgcWebPushMessage | Structured notification (Title/Body/Icon/Url) serialized once via AsJSON and reused for each subscription. |
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.
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;
procedure BroadcastNotification(const aMessage: string);
| Name | Type | Description |
|---|---|---|
aMessage | const string | Raw payload (usually JSON) delivered verbatim to every subscriber after per-subscription encryption. |
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.
sgcWSAPIServer_WebPush1.BroadcastNotification(
'{"title":"Heads up","body":"Server restarting in 5 min"}');