TsgcWSAPIServer_WebPush › メソッド › BroadcastNotification
内部のSubscriptionsリストに現在保持されているすべてのサブスクリプションに同じ通知を送信します。
procedure BroadcastNotification(const aMessage : TsgcWebPushMessage);
| 名前 | タイプ | 説明 |
|---|---|---|
aMessage | const TsgcWebPushMessage | AsJSON を介して一度シリアライズされ、各サブスクリプションで再利用される構造化通知 (Title/Body/Icon/Url)。 |
ロック下でスレッドセーフな Subscriptions リストを反復処理し、各エントリに対して SendNotification を呼び出します。送信に失敗した場合、OnWebPushSendNotificationException が発火し、Remove が True(デフォルト)を返した場合、サブスクリプションはリストから自動的に削除されます。プッシュサービスからの404/410レスポンスをクリーンアップするのに最適です。
var
oMessage: TsgcWebPushMessage;
begin
oMessage := TsgcWebPushMessage.Create;
try
oMessage.Title := 'eSeGeCe Notification';
oMessage.Body := 'New version released!!!';
oMessage.Icon := 'https://www.esegece.com/images/esegece_logo_small.png';
oMessage.Url := 'https://www.esegece.com';
sgcWSAPIServer_WebPush1.BroadcastNotification(oMessage);
finally
oMessage.Free;
end;
end;
procedure BroadcastNotification(const aMessage: string);
| 名前 | タイプ | 説明 |
|---|---|---|
aMessage | const string | サブスクリプションごとの暗号化後、すべてのサブスクライバーに逐語的に配信される生のペイロード(通常は JSON)。 |
ブロードキャストペイロードが既にシリアル化されている場合の便利なオーバーロード。永続化を自前で管理している場合は、Subscriptions.AddSubscription/Subscriptions.RemoveSubscription を通じてサブスクリプションを手動で追加または削除できます。
sgcWSAPIServer_WebPush1.BroadcastNotification(
'{"title":"Heads up","body":"Server restarting in 5 min"}');