Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NotificationMessageApple.cs
1using System.Collections.Generic;
2
4{
11 {
16 {
17 }
18
24 public string Sound { get; set; }
25
33 public string Badge { get; set; }
34
38 public string SubTitle { get; set; }
39
47 public string BodyLocalizationKey { get; set; }
48
56 public string[] BodyLocalizationArguments { get; set; }
57
65 public string TitleLocalizationKey { get; set; }
66
74 public string[] TitleLocalizationArguments { get; set; }
75
79 public object AppleSpecificDeliveryOptions { get; set; }
80
85 public override void ExportProperties(Dictionary<string, object> Message)
86 {
87 base.ExportProperties(Message);
88
89 Dictionary<string, object> ApnsConfig = new Dictionary<string, object>();
90 Dictionary<string, object> Payload = new Dictionary<string, object>();
91 Dictionary<string, object> Aps = new Dictionary<string, object>();
92
93 if (!string.IsNullOrEmpty(this.Sound))
94 Aps["sound"] = this.Sound;
95
96 if (!string.IsNullOrEmpty(this.Badge))
97 Aps["badge"] = this.Badge;
98
99 if (!string.IsNullOrEmpty(this.SubTitle))
100 Aps["subtitle"] = this.SubTitle;
101
102 if (!string.IsNullOrEmpty(this.BodyLocalizationKey))
103 {
104 Aps["body_loc_key"] = this.BodyLocalizationKey;
105
106 if (!(this.BodyLocalizationArguments is null))
107 Aps["body_loc_args"] = this.BodyLocalizationArguments;
108 }
109
110 if (!string.IsNullOrEmpty(this.TitleLocalizationKey))
111 {
112 Aps["title_loc_key"] = this.TitleLocalizationKey;
113
114 if (!(this.TitleLocalizationArguments is null))
115 Aps["title_loc_args"] = this.TitleLocalizationArguments;
116 }
117
118 if (Aps.Count > 0)
119 Payload["aps"] = Aps;
120
121 if (Payload.Count > 0)
122 ApnsConfig["payload"] = Payload;
123
124
125 if (this.AppleSpecificDeliveryOptions is Dictionary<string, object> ApnsConfig2)
126 {
127 foreach (KeyValuePair<string, object> P in ApnsConfig2)
128 {
129 if (ApnsConfig.TryGetValue(P.Key, out object Obj) &&
130 Obj is Dictionary<string, object> Obj1 &&
131 P.Value is Dictionary<string, object> Obj2)
132 {
133 foreach (KeyValuePair<string, object> P2 in Obj2)
134 {
135 if (Obj1.TryGetValue(P2.Key, out object Obj3) &&
136 Obj3 is Dictionary<string, object> Obj31 &&
137 P2.Value is Dictionary<string, object> Obj32)
138 {
139 foreach (KeyValuePair<string, object> P3 in Obj32)
140 {
141 Obj31[P3.Key] = P3.Value;
142 }
143 }
144 else
145 Obj1[P2.Key] = P2.Value;
146 }
147 }
148 else
149 ApnsConfig[P.Key] = P.Value;
150 }
151 }
152
153 if (ApnsConfig.Count > 0)
154 Message["apns"] = ApnsConfig;
155 }
156
163 public override bool TrySetProperty(string Name, object Value)
164 {
165 switch (Name)
166 {
167 case "sound":
168 this.Sound = Value?.ToString();
169 return true;
170
171 case "badge":
172 this.Badge = Value?.ToString();
173 return true;
174
175 case "subtitle":
176 this.SubTitle = Value?.ToString();
177 return true;
178
179 case "body_loc_key":
180 this.BodyLocalizationKey = Value?.ToString();
181 return true;
182
183 case "body_loc_args":
184 if (Value is string[] BodyLocalizationArguments)
185 {
186 this.BodyLocalizationArguments = BodyLocalizationArguments;
187 return true;
188 }
189 break;
190
191 case "title_loc_key":
192 this.TitleLocalizationKey = Value?.ToString();
193 return true;
194
195 case "title_loc_args":
196 if (Value is string[] TitleLocalizationArguments)
197 {
198 this.TitleLocalizationArguments = TitleLocalizationArguments;
199 return true;
200 }
201 break;
202
203 case "apns":
204 this.AppleSpecificDeliveryOptions = Value;
205 break;
206 }
207
208 return base.TrySetProperty(Name, Value);
209 }
210
211 }
212}
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.
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...
override bool TrySetProperty(string Name, object Value)
Tries to set a property value.