Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NotificationOptions.cs
1using System;
2using System.Collections.Generic;
3
5{
12 {
17 {
18 this.Priority = NotificationPriority.Normal;
19 this.TimeToLive = 0; // Represent default TTL (i.e. 60 * 60 * 24 * 7 * 4 = 4 weeks, in seconds.)
20 }
21
29 public string Condition { get; set; }
30
34 public string MessageId { get; set; }
35
43 public string CollapseKey { get; set; }
44
52 public NotificationPriority Priority { get; set; }
53
57 public bool ContentAvailable { get; set; }
58
62 public bool MutableContent { get; set; }
63
69 public bool DryRun { get; set; }
70
74 public int TimeToLive { get; set; }
75
81 public void SetProperties(Dictionary<string, object> Message, FirebaseClient Client)
82 {
83 if (!string.IsNullOrEmpty(this.Condition))
84 Message["condition"] = this.Condition;
85
86 if (!string.IsNullOrEmpty(this.MessageId))
87 Message["name"] = "projects/" + Client.ProjectId + "/messages/" + this.MessageId;
88
89 if (!string.IsNullOrEmpty(this.CollapseKey))
90 Message["collapse_key"] = this.CollapseKey;
91
92 if (this.Priority != NotificationPriority.Normal)
93 Message["priority"] = this.Priority.ToString().ToLower();
94
95 if (this.ContentAvailable)
96 Message["content_available"] = this.ContentAvailable;
97
98 if (this.MutableContent)
99 Message["mutable_content"] = this.MutableContent;
100
101 if (this.TimeToLive > 0)
102 Message["time_to_live"] = this.TimeToLive;
103
104 if (this.DryRun)
105 Message["dry_run"] = this.DryRun;
106 }
107
114 public bool TrySetProperty(string Name, object Value)
115 {
116 switch (Name)
117 {
118 case "condition":
119 if (Value is string Condition)
120 {
121 this.Condition = Condition;
122 return true;
123 }
124 break;
125
126 case "message_id":
127 if (Value is string MessageId)
128 {
129 this.MessageId = MessageId;
130 return true;
131 }
132 break;
133
134 case "collapse_key":
135 if (Value is string CollapseKey)
136 {
137 this.CollapseKey = CollapseKey;
138 return true;
139 }
140 break;
141
142 case "priority":
143 if (Value is string s)
144 {
145 if (Enum.TryParse<NotificationPriority>(s, out NotificationPriority Priority))
146 {
147 this.Priority = Priority;
148 return true;
149 }
150 else if (int.TryParse(s, out int i))
151 {
152 this.Priority = (NotificationPriority)i;
153 return true;
154 }
155 }
156 break;
157
158 case "content_available":
159 if (Value is bool ContentAvailable)
160 {
161 this.ContentAvailable = ContentAvailable;
162 return true;
163 }
164 break;
165
166 case "mutable_content":
167 if (Value is bool MutableContent)
168 {
169 this.MutableContent = MutableContent;
170 return true;
171 }
172 break;
173
174 case "time_to_live":
175 if (Value is int TimeToLive)
176 {
177 this.TimeToLive = TimeToLive;
178 return true;
179 }
180 break;
181
182 case "dry_run":
183 if (Value is bool DryRun)
184 {
185 this.DryRun = DryRun;
186 return true;
187 }
188 break;
189 }
190
191 return false;
192 }
193
194 }
195}
bool DryRun
This parameter, when set to true, allows developers to test a request without actually sending a mess...
string Condition
This parameter specifies a logical expression of conditions that determines the message target.
bool TrySetProperty(string Name, object Value)
Tries to set a property value.
string CollapseKey
This parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can...
bool MutableContent
On Apple platforms, use this field to represent mutable-content in the APNs payload....
void SetProperties(Dictionary< string, object > Message, FirebaseClient Client)
Prepares the object to send to Firebase.
bool ContentAvailable
On Apple platforms, use this field to represent content-available in the APNs payload....
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." On Apple platforms,...
string MessageId
This parameter uniquely identifies a message in an XMPP connection.
NotificationPriority
Notification priority