TsgcWSAPIServer_WebPushEvents › OnWebPushUnsubscription

OnWebPushUnsubscription Event

Fires when a browser POSTs to the Unsubscription endpoint (PushManager.unsubscribe() or service-worker change); use it to remove the subscription from your persistent store.

Syntax

property OnWebPushUnsubscription: TsgcWSWebPushUnsubscription;
// TsgcWSWebPushUnsubscription = procedure(Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription; var ResponseCode: Integer) of object

Default Value

Remarks

The internal Subscriptions list is automatically updated via Subscriptions.RemoveSubscription, so BroadcastNotification no longer targets the unsubscribed endpoint. Mirror the deletion on your own storage so stale records are not retained. Set ResponseCode to the HTTP status sent back to the browser — normally 200 on success.

Example

procedure TForm1.sgcWSAPIServer_WebPush1WebPushUnsubscription(Sender: TObject;
  aSubscription: TsgcHTTP_API_WebPush_PushSubscription; var ResponseCode: Integer);
begin
  DeleteSubscriptionFromDB(aSubscription.Endpoint);
  ResponseCode := 200;
end;

Back to Events