Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NotificationMessage.cs
1using System.Collections.Generic;
2
4{
11 {
16 {
17 }
18
24 public string Title { get; set; }
25
29 public string Body { get; set; }
30
36 public string ClickAction { get; set; }
37
42 public virtual Dictionary<string, object> GetNotificationObject()
43 {
44 Dictionary<string, object> Result = new Dictionary<string, object>();
45
46 if (!string.IsNullOrEmpty(this.Title))
47 Result["title"] = this.Title;
48
49 if (!string.IsNullOrEmpty(this.Body))
50 Result["body"] = this.Body;
51
52 if (!string.IsNullOrEmpty(this.ClickAction))
53 Result["click_action"] = this.ClickAction;
54
55 return Result;
56 }
57
62 public virtual void ExportProperties(Dictionary<string, object> Message)
63 {
64 // Nothing by default
65 }
66
73 public virtual bool TrySetProperty(string Name, object Value)
74 {
75 switch (Name)
76 {
77 case "title":
78 if (Value is string Title)
79 {
80 this.Title = Title;
81 return true;
82 }
83 break;
84
85 case "body":
86 if (Value is string Body)
87 {
88 this.Body = Body;
89 return true;
90 }
91 break;
92
93 case "click_action":
94 if (Value is string ClickAction)
95 {
96 this.ClickAction = ClickAction;
97 return true;
98 }
99 break;
100
101 case "android":
102 case "apns":
103 case "webpush":
104 return true; // Ignore by default.
105 }
106
107 return false;
108 }
109
110 }
111}
NotificationMessage()
Base class for Notification messages
virtual bool TrySetProperty(string Name, object Value)
Tries to set a property value.
virtual Dictionary< string, object > GetNotificationObject()
Gets the notification object for a push notification.
string ClickAction
The action associated with a user click on the notification.
virtual void ExportProperties(Dictionary< string, object > Message)
Prepares the object to send to Firebase.