Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NotificationMessageWeb.cs
2
4{
11 {
16 {
17 }
18
22 public string Link { get; set; }
23
27 public string Icon { get; set; }
28
32 public object WebPushSpecificDeliveryOptions { get; set; }
33
38 public override void ExportProperties(Dictionary<string, object> Message)
39 {
40 base.ExportProperties(Message);
41
42 Dictionary<string, object> WebPushConfig = Message.ContainsKey("webpush") && Message["webpush"] is Dictionary<string, object> ExistingWebpush
43 ? ExistingWebpush
44 : new Dictionary<string, object>();
45 Dictionary<string, object> WebPushNotification = new Dictionary<string, object>();
46 Dictionary<string, object> WebPushFcmOptions = new Dictionary<string, object>();
47
48 if (!this.SuppressNotification)
49 {
50 if (!string.IsNullOrEmpty(this.Link))
51 WebPushFcmOptions["link"] = this.Link;
52
53 if (!string.IsNullOrEmpty(this.Title))
54 WebPushNotification["title"] = this.Title;
55
56 if (!string.IsNullOrEmpty(this.Body))
57 WebPushNotification["body"] = this.Body;
58
59 if (!string.IsNullOrEmpty(this.Icon))
60 WebPushNotification["icon"] = this.Icon;
61
62 if (WebPushNotification.Count > 0)
63 WebPushConfig["notification"] = WebPushNotification;
64
65 if (WebPushFcmOptions.Count > 0)
66 WebPushConfig["fcm_options"] = WebPushFcmOptions;
67 }
68
69
70 if (this.WebPushSpecificDeliveryOptions is Dictionary<string, object> WebPushConfig2)
71 {
72 foreach (KeyValuePair<string, object> P in WebPushConfig2)
73 {
74 if (WebPushConfig.TryGetValue(P.Key, out object Obj) &&
75 Obj is Dictionary<string, object> Obj1 &&
76 P.Value is Dictionary<string, object> Obj2)
77 {
78 foreach (KeyValuePair<string, object> P2 in Obj2)
79 Obj1[P2.Key] = P2.Value;
80 }
81 else
82 WebPushConfig[P.Key] = P.Value;
83 }
84 }
85
86 if (WebPushConfig.Count > 0)
87 Message["webpush"] = WebPushConfig;
88 }
89
96 public override bool TrySetProperty(string Name, object Value)
97 {
98 switch (Name)
99 {
100 case "link":
101 this.Link = Value?.ToString();
102 return true;
103
104 case "icon":
105 this.Icon = Value?.ToString();
106 return true;
107
108 case "webpush":
109 this.WebPushSpecificDeliveryOptions = Value;
110 break;
111 }
112
113 return base.TrySetProperty(Name, Value);
114 }
115
116 }
117}
bool SuppressNotification
If the visual notification part should be suppressed (data-only/background).
override void ExportProperties(Dictionary< string, object > Message)
Prepares the object to send to Firebase.
object WebPushSpecificDeliveryOptions
Web-Push-specific delivery options.
override bool TrySetProperty(string Name, object Value)
Tries to set a property value.
string Icon
Icon to display with the notification.