25 public string Sound {
get;
set; }
34 public string Badge {
get;
set; }
98 base.ExportProperties(Message);
100 Dictionary<string, object> ApnsConfig = Message.ContainsKey(
"apns") && Message[
"apns"] is Dictionary<string, object> ExistingApns
102 :
new Dictionary<string, object>();
103 Dictionary<string, object> Payload = ApnsConfig.ContainsKey(
"payload") && ApnsConfig[
"payload"] is Dictionary<string, object> ExistingPayload
105 :
new Dictionary<string, object>();
106 Dictionary<string, object> Aps = Payload.ContainsKey(
"aps") && Payload[
"aps"] is Dictionary<string, object> ExistingAps
108 :
new Dictionary<string, object>();
109 Dictionary<string, object> Headers = ApnsConfig.ContainsKey(
"headers") && ApnsConfig[
"headers"] is Dictionary<string, object> ExistingHeaders
111 :
new Dictionary<string, object>();
112 Dictionary<string, object> Alert =
new Dictionary<string, object>();
115 this.ContentAvailable =
true;
120 Headers[
"apns-priority"] = ((int)EffectivePriority).ToString();
125 long ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(this.
TimeToLive).ToUnixTimeSeconds();
126 Headers[
"apns-expiration"] = ExpirationTime.ToString();
131 if (!
string.IsNullOrEmpty(this.
Title))
132 Alert[
"title"] = this.
Title;
134 if (!
string.IsNullOrEmpty(this.
Body))
135 Alert[
"body"] = this.
Body;
137 if (!
string.IsNullOrEmpty(this.
SubTitle))
143 Aps[
"sound"] = this.
Sound;
146 Aps[
"badge"] = this.
Badge;
165 Aps[
"content-available"] = 1;
168 Aps[
"mutable-content"] = 1;
171 Aps[
"alert"] = Alert;
174 Payload[
"aps"] = Aps;
176 if (Payload.Count > 0)
177 ApnsConfig[
"payload"] = Payload;
180 if (Headers.Count > 0)
181 ApnsConfig[
"headers"] = Headers;
183 if (!ApnsConfig.TryGetValue(
"headers", out
object HeadersObj) || !(HeadersObj is Dictionary<string, object> HeadersFinal))
185 HeadersFinal = Headers.Count > 0 ?
new Dictionary<string, object>(Headers) :
new Dictionary<string, object>();
186 ApnsConfig[
"headers"] = HeadersFinal;
189 string PushType = (Alert.Count > 0 || !
string.IsNullOrEmpty(this.
Sound) || !
string.IsNullOrEmpty(this.
Badge)) ?
"alert" :
"background";
190 HeadersFinal[
"apns-push-type"] = PushType;
192 if (Headers.Count > 0)
193 ApnsConfig[
"headers"] = Headers;
197 foreach (KeyValuePair<string, object> P
in ApnsConfig2)
199 if (ApnsConfig.TryGetValue(P.Key, out
object Obj) &&
200 Obj is Dictionary<string, object> Obj1 &&
201 P.Value is Dictionary<string, object> Obj2)
203 foreach (KeyValuePair<string, object> P2
in Obj2)
205 if (Obj1.TryGetValue(P2.Key, out
object Obj3) &&
206 Obj3 is Dictionary<string, object> Obj31 &&
207 P2.Value is Dictionary<string, object> Obj32)
209 foreach (KeyValuePair<string, object> P3
in Obj32)
211 Obj31[P3.Key] = P3.Value;
215 Obj1[P2.Key] = P2.Value;
219 ApnsConfig[P.Key] = P.Value;
223 if (ApnsConfig.Count > 0)
224 Message[
"apns"] = ApnsConfig;
237 case "apns-push-type":
238 this.AddHeader(
"apns-push-type", Value);
242 this.AddHeader(
"apns-topic", Value);
246 this.Sound = Value?.ToString();
250 this.Badge = Value?.ToString();
254 this.SubTitle = Value?.ToString();
258 this.BodyLocalizationKey = Value?.ToString();
261 case "body_loc_args":
269 case "title_loc_key":
270 this.TitleLocalizationKey = Value?.ToString();
273 case "title_loc_args":
281 case "content_available":
289 case "mutable_content":
298 this.AppleSpecificDeliveryOptions = Value;
302 return base.TrySetProperty(Name, Value);
305 private void AddHeader(
string Name,
object Value)
312 Options =
new Dictionary<string, object>();
313 this.AppleSpecificDeliveryOptions = Options;
316 if (!Options.TryGetValue(
"headers", out
object HeadersObj) || !(HeadersObj is Dictionary<string, object> Headers))
318 Headers =
new Dictionary<string, object>();
319 Options[
"headers"] = Headers;
322 Headers[Name] = Value.ToString();
Notification message for Apple
string Sound
The sound to play when the device receives the notification.
string[] BodyLocalizationArguments
Variable string values to be used in place of the format specifiers in body_loc_key to use to localiz...
object AppleSpecificDeliveryOptions
Apple-specific delivery options.
string Badge
The value of the badge on the home screen app icon.
bool ContentAvailable
On Apple platforms, this field indicates if the notification should wake an inactive client app (cont...
NotificationMessageApple()
Notification message for Apple
string BodyLocalizationKey
The key to the body string in the app's string resources to use to localize the body text to the user...
override void ExportProperties(Dictionary< string, object > Message)
Prepares the object to send to Firebase.
string TitleLocalizationKey
The key to the title string in the app's string resources to use to localize the title text to the us...
string[] TitleLocalizationArguments
Variable string values to be used in place of the format specifiers in title_loc_key to use to locali...
bool MutableContent
On Apple platforms, this indicates if notification content can be modified before display (mutable-co...
string SubTitle
The notification's subtitle.
override bool TrySetProperty(string Name, object Value)
Tries to set a property value.
Base class for Notification messages
bool SuppressNotification
If the visual notification part should be suppressed (data-only/background).
string Title
The notification's title.
string Body
The notification's body text.
int TimeToLive
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the devic...
NotificationPriority Priority
Sets the priority of the message. Valid values are "normal" and "high."
NotificationPriority
Notification priority