TsgcWSAPIServer_WebPushOlaylar › OnWebPushSubscription

OnWebPushSubscription Olay

Bir tarayıcı, PushManager.subscribe() çağrısından sonra Subscription uç noktasına POST yaptığında tetiklenir; sunucu tarafında kalıcı hâle getirmek için uç noktayı, p256dh anahtarını ve auth secret'ı alın.

Sözdizimi

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

Varsayılan Değer

Remarks

Bileşen, yeni aboneliği zaten dahili Subscriptions listesinde depolar, böylece BroadcastNotification tarafından erişilebilir hale gelir. Gelen aboneliği kendi veritabanınıza kalıcı hale getirmek ve/veya sunucu tarafı doğrulaması (kimlik doğrulama, oran sınırlama, yinelenen tespiti) uygulamak için olayı kullanın. ResponseCode değerini tarayıcıya döndürülen HTTP durumuna ayarlayın — başarıda 200/201 döndürün veya reddetmek için bir 4xx (örneğin kullanıcı yetkili değilse 401).

Örnek

procedure TForm1.sgcWSAPIServer_WebPush1WebPushSubscription(Sender: TObject;
  aSubscription: TsgcHTTP_API_WebPush_PushSubscription; var ResponseCode: Integer);
begin
  SaveSubscriptionToDB(aSubscription.Endpoint,
                       aSubscription.PublicKey,
                       aSubscription.AuthSecret);
  ResponseCode := 201;
end;

Olaylara Dön