TsgcWSAPIServer_WebPush事件 › OnWebPushUnsubscription

OnWebPushUnsubscription 事件

当浏览器 POST 到取消订阅端点(PushManager.unsubscribe() 或 service-worker 变更)时触发;使用此事件从持久存储中移除订阅。

语法

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

默认值

备注

内部 Subscriptions 列表通过 Subscriptions.RemoveSubscription 自动更新,因此 BroadcastNotification 不再以取消订阅的端点为目标。在您自己的存储中镜像删除操作,以避免保留过期记录。将 ResponseCode 设为发送回浏览器的 HTTP 状态——成功时通常为 200。

示例

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

返回事件