Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NotificationMessageAndroid.cs
1using System.Collections.Generic;
2
4{
11 {
16 {
17 }
18
26 public string ChannelId { get; set; }
27
33 public string Sound { get; set; }
34
42 public string Tag { get; set; }
43
47 public string Color { get; set; }
48
54 public string BodyLocalizationKey { get; set; }
55
61 public string[] BodyLocalizationArguments { get; set; }
62
68 public string TitleLocalizationKey { get; set; }
69
75 public string[] TitleLocalizationArguments { get; set; }
76
82 public string Icon { get; set; }
83
87 public object AndroidSpecificDeliveryOptions { get; set; }
88
93 public override void ExportProperties(Dictionary<string, object> Message)
94 {
95 base.ExportProperties(Message);
96
97 Dictionary<string, object> AndroidConfig = new Dictionary<string, object>();
98 Dictionary<string, object> AndroidNotification = new Dictionary<string, object>();
99
100 if (!string.IsNullOrEmpty(this.ChannelId))
101 AndroidNotification["channel_id"] = this.ChannelId;
102
103 if (!string.IsNullOrEmpty(this.Sound))
104 AndroidNotification["sound"] = this.Sound;
105
106 if (!string.IsNullOrEmpty(this.Tag))
107 AndroidNotification["tag"] = this.Tag;
108
109 if (!string.IsNullOrEmpty(this.Color))
110 AndroidNotification["color"] = this.Color;
111
112 if (!string.IsNullOrEmpty(this.Icon))
113 AndroidNotification["icon"] = this.Icon;
114
115 if (!string.IsNullOrEmpty(this.BodyLocalizationKey))
116 {
117 AndroidNotification["body_loc_key"] = this.BodyLocalizationKey;
118
119 if (!(this.BodyLocalizationArguments is null))
120 AndroidNotification["body_loc_args"] = this.BodyLocalizationArguments;
121 }
122
123 if (!string.IsNullOrEmpty(this.TitleLocalizationKey))
124 {
125 AndroidNotification["title_loc_key"] = this.TitleLocalizationKey;
126
127 if (!(this.TitleLocalizationArguments is null))
128 AndroidNotification["title_loc_args"] = this.TitleLocalizationArguments;
129 }
130
131 if (AndroidNotification.Count > 0)
132 AndroidConfig["notification"] = AndroidNotification;
133
134 if (this.AndroidSpecificDeliveryOptions is Dictionary<string, object> Android2)
135 {
136 foreach (KeyValuePair<string, object> P in Android2)
137 {
138 if (AndroidConfig.TryGetValue(P.Key, out object Obj) &&
139 Obj is Dictionary<string, object> Obj1 &&
140 P.Value is Dictionary<string, object> Obj2)
141 {
142 foreach (KeyValuePair<string, object> P2 in Obj2)
143 Obj1[P2.Key] = P2.Value;
144 }
145 else
146 AndroidConfig[P.Key] = P.Value;
147 }
148 }
149
150 if (AndroidConfig.Count > 0)
151 Message["android"] = AndroidConfig;
152 }
153
160 public override bool TrySetProperty(string Name, object Value)
161 {
162 switch (Name)
163 {
164 case "android_channel_id":
165 case "channel_id":
166 this.ChannelId = Value?.ToString();
167 return true;
168
169 case "sound":
170 this.Sound = Value?.ToString();
171 return true;
172
173 case "tag":
174 this.Tag = Value?.ToString();
175 break;
176
177 case "color":
178 this.Color = Value?.ToString();
179 break;
180
181 case "icon":
182 this.Icon = Value?.ToString();
183 return true;
184
185 case "body_loc_key":
186 this.BodyLocalizationKey = Value?.ToString();
187 return true;
188
189 case "body_loc_args":
190 if (Value is string[] BodyLocalizationArguments)
191 {
192 this.BodyLocalizationArguments = BodyLocalizationArguments;
193 return true;
194 }
195 break;
196
197 case "title_loc_key":
198 this.TitleLocalizationKey = Value?.ToString();
199 return true;
200
201 case "title_loc_args":
202 if (Value is string[] TitleLocalizationArguments)
203 {
204 this.TitleLocalizationArguments = TitleLocalizationArguments;
205 return true;
206 }
207 break;
208
209 case "android":
210 this.AndroidSpecificDeliveryOptions = Value;
211 break;
212 }
213
214 return base.TrySetProperty(Name, Value);
215 }
216 }
217}
string ChannelId
The notification's channel id (new in Android O).
string Color
The notification's icon color, expressed in #rrggbb format.
object AndroidSpecificDeliveryOptions
Android-specific delivery options.
string[] TitleLocalizationArguments
Variable string values to be used in place of the format specifiers in title_loc_key to use to locali...
string BodyLocalizationKey
The key to the body string in the app's string resources to use to localize the body text to the user...
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 Sound
The sound to play when the device receives the notification.
override void ExportProperties(Dictionary< string, object > Message)
Prepares the object to send to Firebase.
string Icon
The URL to use for the notification's icon.
string Tag
Identifier used to replace existing notifications in the notification drawer.
string[] BodyLocalizationArguments
Variable string values to be used in place of the format specifiers in body_loc_key to use to localiz...
override bool TrySetProperty(string Name, object Value)
Tries to set a property value.