Skip to content

Commit 7752b6c

Browse files
Add notification data field.
1 parent 6ee9c86 commit 7752b6c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

sdk/Notifo.SDK/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal static class Constants
2020
public const string LinkUrlKey = "linkUrl";
2121
public const string LinkTextKey = "linkText";
2222
public const string TrackingUrlKey = "trackingUrl";
23+
public const string DataKey = "data";
2324
public const string ApsKey = "aps";
2425
public const string ContentAvailableKey = "content-available";
2526
public const string ApsAlertTitleKey = "aps.alert.title";

sdk/Notifo.SDK/Extensions/NotificationDtoExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public static Dictionary<string, string> ToDictionary(this NotificationDto notif
6666
data[Constants.TrackingUrlKey] = notification.TrackingUrl;
6767
}
6868

69+
if (!string.IsNullOrWhiteSpace(notification.Data))
70+
{
71+
data[Constants.DataKey] = notification.Data;
72+
}
73+
6974
return data;
7075
}
7176

@@ -134,6 +139,11 @@ public static NotificationDto FromDictionary(this NotificationDto notification,
134139
notification.TrackingUrl = trackingUrl.ToString();
135140
}
136141

142+
if (data.TryGetValue(Constants.DataKey, out var notificationData))
143+
{
144+
notification.Data = notificationData.ToString();
145+
}
146+
137147
return notification;
138148
}
139149
}

sdk/Notifo.SDK/PushEventProvider/NotificationEventArgs.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class NotificationEventArgs
7171
/// </summary>
7272
public string? LinkText { get; }
7373

74+
/// <summary>
75+
/// Optional data, usually a json object.
76+
/// </summary>
77+
public string? Data { get; set; }
78+
7479
/// <summary>
7580
/// Initializes a new instance of the <see cref="NotificationEventArgs"/> class.
7681
/// </summary>
@@ -88,6 +93,7 @@ public NotificationEventArgs(NotificationDto notification)
8893
TrackingUrl = notification.TrackingUrl;
8994
LinkUrl = notification.LinkUrl;
9095
LinkText = notification.LinkText;
96+
Data = notification.Data;
9197
}
9298

9399
/// <summary>

0 commit comments

Comments
 (0)