TsgcWSAPIServer_WebPush › Events › OnWebPushUnsubscription
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.
property OnWebPushUnsubscription: TsgcWSWebPushUnsubscription;
// TsgcWSWebPushUnsubscription = procedure(Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription; var ResponseCode: Integer) of object
—
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.
procedure TForm1.sgcWSAPIServer_WebPush1WebPushUnsubscription(Sender: TObject;
aSubscription: TsgcHTTP_API_WebPush_PushSubscription; var ResponseCode: Integer);
begin
DeleteSubscriptionFromDB(aSubscription.Endpoint);
ResponseCode := 200;
end;