16 private Dictionary<string, object> data;
46 if (!(Payload.
Visual is
null))
48 if (!SilentDelivery && !
string.IsNullOrEmpty(Payload.
Visual.
Title))
51 if (!SilentDelivery && !
string.IsNullOrEmpty(Payload.
Visual.
Body))
60 if (!
string.IsNullOrEmpty(Payload.
Visual.
Icon))
72 if (!(Payload.
Action is
null))
82 this.AddData(
"actionType", Payload.
Action.
Type);
100 if (!(Payload.
Context is
null))
102 foreach (KeyValuePair<string, object> P
in Payload.
Context)
103 this.AddData(P.Key, P.Value);
108 foreach (KeyValuePair<string, object> P
in Payload.
CustomData)
109 this.AddData(P.Key, P.Value);
117 this.message.Priority = Priority;
121 this.message.TimeToLive = Payload.
Delivery.
Ttl.Value;
128 this.message.SuppressNotification =
true;
131 switch (this.message)
134 Apple.ContentAvailable =
true;
141 Payload.
PlatformOverrides.TryGetValue(
this.clientType, out Dictionary<string, object> Overrides))
143 foreach (KeyValuePair<string, object> P
in Overrides)
144 this.ApplyOverrideProperty(P.Key, P.Value);
155 this.ValidateNotification();
156 return (this.message, this.options, this.data);
162 private void ValidateNotification()
164 switch (this.clientType)
167 this.ValidateAndroid();
171 this.ValidateApple();
181 private void ValidateAndroid()
183 if (!(this.message is NotificationMessageAndroid Android))
187 if (
string.IsNullOrEmpty(Android.ChannelId))
188 Android.ChannelId =
"default";
191 private void ValidateApple()
193 if (!(this.message is NotificationMessageApple Apple))
197 if (
string.IsNullOrEmpty(Apple.Title) &&
198 string.IsNullOrEmpty(Apple.Body) &&
199 !Apple.ContentAvailable)
201 Apple.ContentAvailable =
true;
205 private void AddData(
string Key,
object Value)
207 if (
string.IsNullOrEmpty(Key) || Value is
null)
210 this.data ??=
new Dictionary<string, object>();
211 this.data[Key] = Value;
214 private void ApplyOverrideProperty(
string Key,
object Value)
217 bool Handled = this.options.TrySetProperty(Key, Value);
220 Handled = this.message.TrySetProperty(Key, Value) || Handled;
223 if (Key ==
"data" && Value is Dictionary<string, object> DataItems)
225 foreach (KeyValuePair<string, object> Item
in DataItems)
226 this.AddData(Item.Key, Item.Value);
229 this.AddData(Key, Value);
Builds Firebase Cloud Messaging notifications with platform-specific validation
NotificationBuilder ApplyPayload(PushNotificationPayload Payload)
Apply a transport-agnostic push payload to the underlying message/options/data.
NotificationMessage message
Build the notification components for sending
NotificationBuilder(ClientType ClientType)
Constructor
Notification message for Android
Notification message for Apple
Base class for Notification messages
Notification message for Web
string EntityId
Entity identifier to act upon.
string CorrelationId
Correlation identifier.
string Type
Action type identifier (e.g. OpenChat, OpenContract).
string NavigationTarget
Client navigation target.
string ChannelId
Channel identifier.
string Importance
Importance level (client defined).
string Category
Category/notification category.
string[] Tags
Tags to help clients route notifications locally.
string Priority
Delivery priority.
int? Ttl
Time to live (seconds).
bool Silent
Flag for silent delivery.
string CollapseKey
Collapse key.
Transport-agnostic push notification payload describing notification intent.
PushVisual Visual
Visual presentation on the device.
PushChannel Channel
Client-side channel/category information.
Dictionary< string, object > Context
Arbitrary context metadata.
Dictionary< string, object > CustomData
Additional custom data to include in the notification payload.
PushDelivery Delivery
Delivery characteristics (priority, TTL, collapse key, silent).
PushAction Action
Action to execute when the notification is acted on.
Dictionary< ClientType, Dictionary< string, object > > PlatformOverrides
Platform-specific override fragments keyed by client type.
string Subtitle
Subtitle text.
string Icon
Icon reference.
NotificationPriority
Notification priority
ClientType
Type of client requesting notification.