TsgcWebPush_Client는 구독 세부 정보를 얻으면 알림을 보낼 수 있게 해주는 클래스입니다.
TsgcWebPush_Client는 구독 세부 정보를 얻으면 알림을 보낼 수 있게 해주는 클래스입니다.
아래에서 WebPush 구독의 endpoint, public key, authentication secret이 주어졌을 때 WebPush 클라이언트를 사용하여 알림을 보내는 예제를 확인하십시오.
procedure SendWebPushNotification;
var
oSubscription: TsgcHTTP_API_WebPush_PushSubscription;
oWebPush: TsgcWebPush_Client ;
begin
oSubscription := TsgcHTTP_API_WebPush_PushSubscription.Create;
try
oSubscription.Endpoint := 'endpoint';
oSubscription.PublicKey := 'public key';
oSubscription.AuthSecret := 'authentication secret';
oWebPush := TsgcHTTP_API_WebPush_Client.Create(nil);
try
oWebPush.VAPID.PEM.PrivateKey.Text := 'private_key_pem';
oWebPush.VAPID.DER.PrivateKey := 'private_key';
oWebPush.VAPID.DER.PublicKey := 'public_key';
oWebPush.SendNotification(oSubscription, '{"title": "eSeGeCe Notification", "body": "Hello from eSeGeCe!!!"}');
finally
oWebPush.Free;
end;
finally
oSubscription.Free;
end;
end;