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;
3
5{
12 {
17 {
18 this.MessageId = Guid.NewGuid().ToString();
19 }
20
24 public string MessageId { get; set; }
25
30 public string CollapseKey { get; set; }
31
37 public string Condition { get; set; }
38
42 public bool DryRun { get; set; }
43
47 public void SetProperties(Dictionary<string, object> Message, FirebaseClient Client)
48 {
49 if (!string.IsNullOrEmpty(this.Condition))
50 Message["condition"] = this.Condition;
51
52 if (!string.IsNullOrEmpty(this.MessageId))
53 Message["name"] = "projects/" + Client.ProjectId + "/messages/" + this.MessageId;
54
55 if (!string.IsNullOrEmpty(this.CollapseKey))
56 {
57 Dictionary<string, object> AndroidConfig = null;
58 if (Message.TryGetValue("android", out object Value))
59 AndroidConfig = Value as Dictionary<string, object>;
60 AndroidConfig ??= new Dictionary<string, object>();
61 AndroidConfig["collapse_key"] = this.CollapseKey;
62 Message["android"] = AndroidConfig;
63 }
64
65 if (this.DryRun)
66 Message["dry_run"] = this.DryRun;
67 }
68
72 public bool TrySetProperty(string Name, object Value)
73 {
74 switch (Name)
75 {
76 case "message_id":
77 if (Value is string MessageId)
78 {
79 this.MessageId = MessageId;
80 return true;
81 }
82 break;
83
84 case "collapse_key":
85 if (Value is string CollapseKey)
86 {
87 this.CollapseKey = CollapseKey;
88 return true;
89 }
90 break;
91
92 case "condition":
93 if (Value is string Condition)
94 {
95 this.Condition = Condition;
96 return true;
97 }
98 break;
99
100 case "dry_run":
101 if (Value is bool DryRun)
102 {
103 this.DryRun = DryRun;
104 return true;
105 }
106 break;
107 }
108
109 return false;
110 }
111 }
112}
bool DryRun
If true, allows testing a request without sending a message.
string Condition
Topic-based message targeting condition. Format: "'yourTopic' in topics". Case-insensitive....
bool TrySetProperty(string Name, object Value)
Tries to set a property value.
string CollapseKey
This parameter identifies a group of messages that can be collapsed. Maximum of 4 different collapse ...
void SetProperties(Dictionary< string, object > Message, FirebaseClient Client)
Prepares the object to send to Firebase.
NotificationOptions()
Notification options for FCM transport settings
string MessageId
This parameter uniquely identifies a message in an FCM connection.