-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathAdmNotification.cs
More file actions
58 lines (43 loc) · 1.41 KB
/
AdmNotification.cs
File metadata and controls
58 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using PushSharp.Common;
namespace PushSharp.Amazon
{
public class AdmNotification : INotification
{
public AdmNotification ()
{
Data = new Dictionary<string, string> ();
}
public Dictionary<string, string> Data { get; set; }
public string ConsolidationKey { get;set; }
public int? ExpiresAfter { get;set; }
public string RegistrationId { get;set; }
public string ToJson()
{
var json = new JObject ();
var data = new JObject ();
if (Data != null && Data.Count > 0) {
foreach (var key in Data.Keys)
data [key] = Data [key];
}
json ["data"] = data;
if (!string.IsNullOrEmpty (ConsolidationKey))
json ["consolidationKey"] = ConsolidationKey;
if (ExpiresAfter.HasValue && ExpiresAfter.Value >= 0)
json ["expiresAfter"] = ExpiresAfter.Value;
return json.ToString();
}
public override string ToString ()
{
return ToJson ();
}
#region INotification implementation
public bool IsDeviceRegistrationIdValid ()
{
return !string.IsNullOrWhiteSpace (RegistrationId);
}
public object Tag { get; set; }
#endregion
}
}