TsgcWSAPIServer_WebPushイベント › OnWebPushUnsubscription

OnWebPushUnsubscription イベント

ブラウザが Unsubscription エンドポイント(PushManager.unsubscribe() またはサービスワーカーの変更)に POST したときに発生します。サブスクリプションを永続ストアから削除するために使用します。

構文

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

デフォルト値

解説

内部の Subscriptions リストは Subscriptions.RemoveSubscription を通じて自動的に更新されるため、BroadcastNotification はサブスクライブ解除されたエンドポイントをターゲットにしなくなります。古いレコードが保持されないよう、独自のストレージ上でも削除を反映してください。ブラウザーに返す HTTP ステータスに ResponseCode を設定してください。通常は成功時に 200 を使用します。

使用例

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

イベントに戻る