TsgcWSAPIServer_WebPushEvents › OnWebPushSendNotificationException

OnWebPushSendNotificationException Event

Fires when an exception is raised while POSTing a notification to the push service (typical causes: 400 Bad Request, 404/410 Gone for expired endpoints, TLS or network failures).

Syntax

property OnWebPushSendNotificationException: TsgcWSWebPushSendNotificationException;
// TsgcWSWebPushSendNotificationException = procedure(Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription; E: Exception; var Remove: Boolean) of object

Default Value

Remarks

Raised from both SendNotification and the per-subscriber loop inside BroadcastNotification. The Remove var-parameter defaults to True: leaving it as-is drops the offending subscription from the internal list (the correct behaviour for permanent failures such as HTTP 410 Gone). Set it to False to keep the subscription and retry later, for example when the failure is transient (network timeout, 5xx from the push service). Use E for logging and diagnostics.

Example

procedure TForm1.sgcWSAPIServer_WebPush1WebPushSendNotificationException(
  Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription;
  E: Exception; var Remove: Boolean);
begin
  LogError(aSubscription.Endpoint, E.Message);
  // keep subscription on transient errors, remove it on permanent ones
  Remove := Pos('410', E.Message) > 0;
end;

Back to Events