TsgcWSAPIServer_WebPush › 메서드 › SendNotification
구성된 VAPID 자격 증명을 사용하여 단일 subscription 엔드포인트에 Web Push 알림을 암호화하고 POST합니다.
procedure SendNotification(const aSubscription : TsgcHTTP_API_WebPush_PushSubscription; const aMessage: TsgcWebPushMessage);
| Name | Type | 설명 |
|---|---|---|
aSubscription | const TsgcHTTP_API_WebPush_PushSubscription | push 서비스 Endpoint와 페이로드 암호화에 사용되는 브라우저의 p256dh PublicKey 및 AuthSecret을 전달하는 대상 구독입니다. |
aMessage | const TsgcWebPushMessage | Title, Body, Icon 및 Url을 포함한 구조화된 메시지입니다. 암호화 전에 AsJSON을 통해 JSON으로 직렬화됩니다. |
라이브러리가 브라우저의 서비스 워커를 위한 올바른 형식의 알림 페이로드를 빌드하기를 원할 때 선호되는 오버로드입니다. 메시지의 AsJSON 표현은 구독의 키를 사용하여 aes128gcm으로 암호화되고 RFC 8030에 따라 푸시 서비스로 POST됩니다.
var
oMessage: TsgcWebPushMessage;
begin
oMessage := TsgcWebPushMessage.Create;
try
oMessage.Title := 'eSeGeCe Notification';
oMessage.Body := 'Subscription Successfully Registered!!!';
oMessage.Icon := 'https://www.esegece.com/images/esegece_logo_small.png';
oMessage.Url := 'https://www.esegece.com';
sgcWSAPIServer_WebPush1.SendNotification(aSubscription, oMessage);
finally
oMessage.Free;
end;
end;
procedure SendNotification(const aSubscription : TsgcHTTP_API_WebPush_PushSubscription; const aMessage: string);
| Name | Type | 설명 |
|---|---|---|
aSubscription | const TsgcHTTP_API_WebPush_PushSubscription | Endpoint, PublicKey(p256dh) 및 AuthSecret이 암호화된 POST를 구동하는 대상 구독입니다. |
aMessage | const string | 암호화 후 그대로 전송되는 원시 페이로드입니다. 일반적으로 서비스 워커가 파싱하는 방법을 아는 JSON 문자열입니다. |
사전 빌드된 JSON 또는 일반 텍스트 페이로드(예: TsgcJSON로 생성되거나 저장소에서 로드됨)를 이미 보유하고 있는 경우 이 오버로드를 사용하십시오. 푸시 서비스는 일반적으로 최대 ~4 KB의 암호화된 콘텐츠를 허용합니다. 이를 초과하면 413 응답이 트리거되며, 이는 OnWebPushSendNotificationException을 통해 다시 발생됩니다.
sgcWSAPIServer_WebPush1.SendNotification(aSubscription,
'{"title":"Hello","body":"Raw JSON payload","data":{"url":"https://www.esegece.com"}}');