Path: redb-route/redb.Route.Firebase/Fcm/FcmEndpointOptions.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Firebase/Fcm/FcmEndpointOptions.cs
----
using redb.Route.Core;
namespace redb.Route.Firebase;
///
/// Endpoint options for the FCM (Firebase Cloud Messaging) component.
/// FCM is producer-only — push notifications are sent to devices, topics, or conditions.
///
public sealed class FcmEndpointOptions : EndpointOptions
{
// ── Auth ──
/// Path to the Firebase service-account JSON file.
public string? CredentialPath { get; set; }
/// Firebase project ID.
public string? ProjectId { get; set; }
/// Named reference from the registry.
[RegistryReference(typeof(IFirebaseCredentialProvider))]
public string? ConnectionFactory { get; set; }
// ── Operation ──
/// Producer operation: Send (default), Multicast, Subscribe/UnsubscribeFromTopic.
public FcmOperationType Operation { get; set; } = FcmOperationType.Send;
// ── Target ──
/// Message target type: Token, Topic, or Condition (Send operation only).
public FcmMessageType MessageType { get; set; } = FcmMessageType.Token;
/// Device registration token. Supports ${...} expressions.
[Sensitive]
public DynamicValue? Token { get; set; }
/// Topic name for topic-based targeting. Supports ${...} expressions.
public DynamicValue? Topic { get; set; }
/// Topic condition expression. Supports ${...} expressions.
public DynamicValue? Condition { get; set; }
// ── Notification ──
/// Notification title. Supports ${...} expressions.
public DynamicValue? Title { get; set; }
/// Notification body text. Overrides exchange.In.Body. Supports ${...} expressions.
public DynamicValue? Body { get; set; }
/// Notification image URL.
public string? ImageUrl { get; set; }
// ── Android ──
/// Android notification priority: "normal" or "high".
public string? AndroidPriority { get; set; }
/// Time-to-live for Android push notifications (seconds).
public int? AndroidTtlSeconds { get; set; }
/// Android notification channel ID.
public string? AndroidChannelId { get; set; }
// ── APNS (iOS) ──
/// APNS priority: "5" (normal) or "10" (immediate).
public string? ApnsPriority { get; set; }
/// APNS collapse identifier for notification grouping.
public string? ApnsCollapseId { get; set; }
/// Enable APNS content-available for background updates.
public bool? ApnsContentAvailable { get; set; }
/// Enable APNS mutable-content for Notification Service Extension.
public bool? ApnsMutableContent { get; set; }
// ── Web (VAPID) ──
/// Click action URL for web push notifications.
public string? WebPushLink { get; set; }
// ── Data ──
/// Send as data-only message (no visible notification).
public bool DataOnly { get; set; }
/// Validate message without actually sending.
public bool DryRun { get; set; }
///
public override void Validate()
{
if (string.IsNullOrWhiteSpace(CredentialPath)
&& string.IsNullOrWhiteSpace(ConnectionFactory)
&& string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS")))
throw new ArgumentOutOfRangeException(nameof(CredentialPath),
"CredentialPath, ConnectionFactory, or GOOGLE_APPLICATION_CREDENTIALS is required");
// Target checks apply to the classic Send only: multicast takes tokens from the
// body/header, topic management takes the Topic option.
if (Operation == FcmOperationType.Send)
{
if (MessageType == FcmMessageType.Token && Token is null)
throw new ArgumentOutOfRangeException(nameof(Token),
"Token is required for Token message type");
if (MessageType == FcmMessageType.Topic && Topic is null)
throw new ArgumentOutOfRangeException(nameof(Topic),
"Topic is required for Topic message type");
if (MessageType == FcmMessageType.Condition && Condition is null)
throw new ArgumentOutOfRangeException(nameof(Condition),
"Condition is required for Condition message type");
}
if (Operation is FcmOperationType.SubscribeToTopic or FcmOperationType.UnsubscribeFromTopic
&& Topic is null)
throw new ArgumentOutOfRangeException(nameof(Topic),
$"Topic is required for the {Operation} operation");
if (AndroidTtlSeconds is not null && AndroidTtlSeconds < 0)
throw new ArgumentOutOfRangeException(nameof(AndroidTtlSeconds),
"AndroidTtlSeconds must be >= 0");
}
}