TsgcWSAPIServer_WebPushEventi › OnWebPushSendNotificationException

OnWebPushSendNotificationException Evento

Generato quando viene sollevata un'eccezione durante l'invio di una notifica al servizio push (cause tipiche: 400 Bad Request, 404/410 Gone per endpoint scaduti, errori TLS o di rete).

Sintassi

property OnWebPushSendNotificationException: TsgcWSWebPushSendNotificationException;
// TsgcWSWebPushSendNotificationException = procedure(Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription; E: Exception; var Remove: Boolean) of object

Valore predefinito

Note

Generato sia da SendNotification che dal ciclo per sottoscrittore all'interno di BroadcastNotification. Il parametro var Remove ha valore predefinito True: lasciandolo invariato si elimina la sottoscrizione problematica dall'elenco interno (il comportamento corretto per errori permanenti come HTTP 410 Gone). Impostarlo a False per mantenere la sottoscrizione e riprovare in seguito, ad esempio quando l'errore è transitorio (timeout di rete, 5xx dal servizio push). Utilizzare E per la registrazione e la diagnostica.

Esempio

procedure TForm1.sgcWSAPIServer_WebPush1WebPushSendNotificationException(
  Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription;
  E: Exception; var Remove: Boolean);
begin
  LogError(aSubscription.Endpoint, E.Message);
  // keep subscription on transient errors, remove it on permanent ones
  Remove := Pos('410', E.Message) > 0;
end;

Torna agli Eventi